home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat1 / perlguts.z / perlguts
Encoding:
Text File  |  2002-10-03  |  151.2 KB  |  4,489 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perlguts - Perl's Internal Functions
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      This document attempts to describe some of the internal functions of the
  13.      Perl executable.  It is far from complete and probably contains many
  14.      errors.  Please refer any questions or comments to the author below.
  15.  
  16. VVVVaaaarrrriiiiaaaabbbblllleeeessss
  17.      DDDDaaaattttaaaattttyyyyppppeeeessss
  18.  
  19.      Perl has three typedefs that handle Perl's three main data types:
  20.  
  21.          SV  Scalar Value
  22.          AV  Array Value
  23.          HV  Hash Value
  24.  
  25.      Each typedef has specific routines that manipulate the various data
  26.      types.
  27.  
  28.      WWWWhhhhaaaatttt iiiissss aaaannnn """"IIIIVVVV""""????
  29.  
  30.      Perl uses a special typedef IV which is a simple integer type that is
  31.      guaranteed to be large enough to hold a pointer (as well as an integer).
  32.  
  33.      Perl also uses two special typedefs, I32 and I16, which will always be at
  34.      least 32-bits and 16-bits long, respectively.
  35.  
  36.      WWWWoooorrrrkkkkiiiinnnngggg wwwwiiiitttthhhh SSSSVVVVssss
  37.  
  38.      An SV can be created and loaded with one command.  There are four types
  39.      of values that can be loaded: an integer value (IV), a double (NV), a
  40.      string, (PV), and another scalar (SV).
  41.  
  42.      The six routines are:
  43.  
  44.          SV*  newSViv(IV);
  45.          SV*  newSVnv(double);
  46.          SV*  newSVpv(char*, int);
  47.          SV*  newSVpvn(char*, int);
  48.          SV*  newSVpvf(const char*, ...);
  49.          SV*  newSVsv(SV*);
  50.  
  51.      To change the value of an *already-existing* SV, there are seven
  52.      routines:
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  71.  
  72.  
  73.  
  74.          void  sv_setiv(SV*, IV);
  75.          void  sv_setuv(SV*, UV);
  76.          void  sv_setnv(SV*, double);
  77.          void  sv_setpv(SV*, char*);
  78.          void  sv_setpvn(SV*, char*, int)
  79.          void  sv_setpvf(SV*, const char*, ...);
  80.          void  sv_setpvfn(SV*, const char*, STRLEN, va_list *, SV **, I32, bool);
  81.          void  sv_setsv(SV*, SV*);
  82.  
  83.      Notice that you can choose to specify the length of the string to be
  84.      assigned by using sv_setpvn, newSVpvn, or newSVpv, or you may allow Perl
  85.      to calculate the length by using sv_setpv or by specifying 0 as the
  86.      second argument to newSVpv.  Be warned, though, that Perl will determine
  87.      the string's length by using strlen, which depends on the string
  88.      terminating with a NUL character.
  89.  
  90.      The arguments of sv_setpvf are processed like sprintf, and the formatted
  91.      output becomes the value.
  92.  
  93.      sv_setpvfn is an analogue of vsprintf, but it allows you to specify
  94.      either a pointer to a variable argument list or the address and length of
  95.      an array of SVs.  The last argument points to a boolean; on return, if
  96.      that boolean is true, then locale-specific information has been used to
  97.      format the string, and the string's contents are therefore untrustworty
  98.      (see the _p_e_r_l_s_e_c manpage).  This pointer may be NULL if that information
  99.      is not important.  Note that this function requires you to specify the
  100.      length of the format.
  101.  
  102.      The sv_set*() functions are not generic enough to operate on values that
  103.      have "magic".  See the section on _M_a_g_i_c _V_i_r_t_u_a_l _T_a_b_l_e_s later in this
  104.      document.
  105.  
  106.      All SVs that contain strings should be terminated with a NUL character.
  107.      If it is not NUL-terminated there is a risk of core dumps and corruptions
  108.      from code which passes the string to C functions or system calls which
  109.      expect a NUL-terminated string.  Perl's own functions typically add a
  110.      trailing NUL for this reason.  Nevertheless, you should be very careful
  111.      when you pass a string stored in an SV to a C function or system call.
  112.  
  113.      To access the actual value that an SV points to, you can use the macros:
  114.  
  115.          SvIV(SV*)
  116.          SvNV(SV*)
  117.          SvPV(SV*, STRLEN len)
  118.  
  119.      which will automatically coerce the actual scalar type into an IV,
  120.      double, or string.
  121.  
  122.      In the SvPV macro, the length of the string returned is placed into the
  123.      variable len (this is a macro, so you do _n_o_t use &len).  If you do not
  124.      care what the length of the data is, use the global variable PL_na.
  125.      Remember, however, that Perl allows arbitrary strings of data that may
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  137.  
  138.  
  139.  
  140.      both contain NULs and might not be terminated by a NUL.
  141.  
  142.      If you want to know if the scalar value is TRUE, you can use:
  143.  
  144.          SvTRUE(SV*)
  145.  
  146.      Although Perl will automatically grow strings for you, if you need to
  147.      force Perl to allocate more memory for your SV, you can use the macro
  148.  
  149.          SvGROW(SV*, STRLEN newlen)
  150.  
  151.      which will determine if more memory needs to be allocated.  If so, it
  152.      will call the function sv_grow.  Note that SvGROW can only increase, not
  153.      decrease, the allocated memory of an SV and that it does not
  154.      automatically add a byte for the a trailing NUL (perl's own string
  155.      functions typically do SvGROW(sv, len + 1)).
  156.  
  157.      If you have an SV and want to know what kind of data Perl thinks is
  158.      stored in it, you can use the following macros to check the type of SV
  159.      you have.
  160.  
  161.          SvIOK(SV*)
  162.          SvNOK(SV*)
  163.          SvPOK(SV*)
  164.  
  165.      You can get and set the current length of the string stored in an SV with
  166.      the following macros:
  167.  
  168.          SvCUR(SV*)
  169.          SvCUR_set(SV*, I32 val)
  170.  
  171.      You can also get a pointer to the end of the string stored in the SV with
  172.      the macro:
  173.  
  174.          SvEND(SV*)
  175.  
  176.      But note that these last three macros are valid only if SvPOK() is true.
  177.  
  178.      If you want to append something to the end of string stored in an SV*,
  179.      you can use the following functions:
  180.  
  181.          void  sv_catpv(SV*, char*);
  182.          void  sv_catpvn(SV*, char*, int);
  183.          void  sv_catpvf(SV*, const char*, ...);
  184.          void  sv_catpvfn(SV*, const char*, STRLEN, va_list *, SV **, I32, bool);
  185.          void  sv_catsv(SV*, SV*);
  186.  
  187.      The first function calculates the length of the string to be appended by
  188.      using strlen.  In the second, you specify the length of the string
  189.      yourself.  The third function processes its arguments like sprintf and
  190.      appends the formatted output.  The fourth function works like vsprintf.
  191.      You can specify the address and length of an array of SVs instead of the
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  203.  
  204.  
  205.  
  206.      va_list argument. The fifth function extends the string stored in the
  207.      first SV with the string stored in the second SV.  It also forces the
  208.      second SV to be interpreted as a string.
  209.  
  210.      The sv_cat*() functions are not generic enough to operate on values that
  211.      have "magic".  See the section on _M_a_g_i_c _V_i_r_t_u_a_l _T_a_b_l_e_s later in this
  212.      document.
  213.  
  214.      If you know the name of a scalar variable, you can get a pointer to its
  215.      SV by using the following:
  216.  
  217.          SV*  perl_get_sv("package::varname", FALSE);
  218.  
  219.      This returns NULL if the variable does not exist.
  220.  
  221.      If you want to know if this variable (or any other SV) is actually
  222.      defined, you can call:
  223.  
  224.          SvOK(SV*)
  225.  
  226.      The scalar undef value is stored in an SV instance called PL_sv_undef.
  227.      Its address can be used whenever an SV* is needed.
  228.  
  229.      There are also the two values PL_sv_yes and PL_sv_no, which contain
  230.      Boolean TRUE and FALSE values, respectively.  Like PL_sv_undef, their
  231.      addresses can be used whenever an SV* is needed.
  232.  
  233.      Do not be fooled into thinking that (SV *) 0 is the same as &PL_sv_undef.
  234.      Take this code:
  235.  
  236.          SV* sv = (SV*) 0;
  237.          if (I-am-to-return-a-real-value) {
  238.                  sv = sv_2mortal(newSViv(42));
  239.          }
  240.          sv_setsv(ST(0), sv);
  241.  
  242.      This code tries to return a new SV (which contains the value 42) if it
  243.      should return a real value, or undef otherwise.  Instead it has returned
  244.      a NULL pointer which, somewhere down the line, will cause a segmentation
  245.      violation, bus error, or just weird results.  Change the zero to
  246.      &PL_sv_undef in the first line and all will be well.
  247.  
  248.      To free an SV that you've created, call SvREFCNT_dec(SV*).  Normally this
  249.      call is not necessary (see the section on _R_e_f_e_r_e_n_c_e _C_o_u_n_t_s _a_n_d
  250.      _M_o_r_t_a_l_i_t_y).
  251.  
  252.      WWWWhhhhaaaatttt''''ssss RRRReeeeaaaallllllllyyyy SSSSttttoooorrrreeeedddd iiiinnnn aaaannnn SSSSVVVV????
  253.  
  254.      Recall that the usual method of determining the type of scalar you have
  255.      is to use Sv*OK macros.  Because a scalar can be both a number and a
  256.      string, usually these macros will always return TRUE and calling the Sv*V
  257.      macros will do the appropriate conversion of string to integer/double or
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  269.  
  270.  
  271.  
  272.      integer/double to string.
  273.  
  274.      If you _r_e_a_l_l_y need to know if you have an integer, double, or string
  275.      pointer in an SV, you can use the following three macros instead:
  276.  
  277.          SvIOKp(SV*)
  278.          SvNOKp(SV*)
  279.          SvPOKp(SV*)
  280.  
  281.      These will tell you if you truly have an integer, double, or string
  282.      pointer stored in your SV.  The "p" stands for private.
  283.  
  284.      In general, though, it's best to use the Sv*V macros.
  285.  
  286.      WWWWoooorrrrkkkkiiiinnnngggg wwwwiiiitttthhhh AAAAVVVVssss
  287.  
  288.      There are two ways to create and load an AV.  The first method creates an
  289.      empty AV:
  290.  
  291.          AV*  newAV();
  292.  
  293.      The second method both creates the AV and initially populates it with
  294.      SVs:
  295.  
  296.          AV*  av_make(I32 num, SV **ptr);
  297.  
  298.      The second argument points to an array containing num SV*'s.  Once the AV
  299.      has been created, the SVs can be destroyed, if so desired.
  300.  
  301.      Once the AV has been created, the following operations are possible on
  302.      AVs:
  303.  
  304.          void  av_push(AV*, SV*);
  305.          SV*   av_pop(AV*);
  306.          SV*   av_shift(AV*);
  307.          void  av_unshift(AV*, I32 num);
  308.  
  309.      These should be familiar operations, with the exception of av_unshift.
  310.      This routine adds num elements at the front of the array with the undef
  311.      value.  You must then use av_store (described below) to assign values to
  312.      these new elements.
  313.  
  314.      Here are some other functions:
  315.  
  316.          I32   av_len(AV*);
  317.          SV**  av_fetch(AV*, I32 key, I32 lval);
  318.          SV**  av_store(AV*, I32 key, SV* val);
  319.  
  320.      The av_len function returns the highest index value in array (just like
  321.      $#array in Perl).  If the array is empty, -1 is returned.  The av_fetch
  322.      function returns the value at index key, but if lval is non-zero, then
  323.      av_fetch will store an undef value at that index.  The av_store function
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  335.  
  336.  
  337.  
  338.      stores the value val at index key, and does not increment the reference
  339.      count of val.  Thus the caller is responsible for taking care of that,
  340.      and if av_store returns NULL, the caller will have to decrement the
  341.      reference count to avoid a memory leak.  Note that av_fetch and av_store
  342.      both return SV**'s, not SV*'s as their return value.
  343.  
  344.          void  av_clear(AV*);
  345.          void  av_undef(AV*);
  346.          void  av_extend(AV*, I32 key);
  347.  
  348.      The av_clear function deletes all the elements in the AV* array, but does
  349.      not actually delete the array itself.  The av_undef function will delete
  350.      all the elements in the array plus the array itself.  The av_extend
  351.      function extends the array so that it contains key elements.  If key is
  352.      less than the current length of the array, then nothing is done.
  353.  
  354.      If you know the name of an array variable, you can get a pointer to its
  355.      AV by using the following:
  356.  
  357.          AV*  perl_get_av("package::varname", FALSE);
  358.  
  359.      This returns NULL if the variable does not exist.
  360.  
  361.      See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d _A_r_r_a_y_s for
  362.      more information on how to use the array access functions on tied arrays.
  363.  
  364.      WWWWoooorrrrkkkkiiiinnnngggg wwwwiiiitttthhhh HHHHVVVVssss
  365.  
  366.      To create an HV, you use the following routine:
  367.  
  368.          HV*  newHV();
  369.  
  370.      Once the HV has been created, the following operations are possible on
  371.      HVs:
  372.  
  373.          SV**  hv_store(HV*, char* key, U32 klen, SV* val, U32 hash);
  374.          SV**  hv_fetch(HV*, char* key, U32 klen, I32 lval);
  375.  
  376.      The klen parameter is the length of the key being passed in (Note that
  377.      you cannot pass 0 in as a value of klen to tell Perl to measure the
  378.      length of the key).  The val argument contains the SV pointer to the
  379.      scalar being stored, and hash is the precomputed hash value (zero if you
  380.      want hv_store to calculate it for you).  The lval parameter indicates
  381.      whether this fetch is actually a part of a store operation, in which case
  382.      a new undefined value will be added to the HV with the supplied key and
  383.      hv_fetch will return as if the value had already existed.
  384.  
  385.      Remember that hv_store and hv_fetch return SV**'s and not just SV*.  To
  386.      access the scalar value, you must first dereference the return value.
  387.      However, you should check to make sure that the return value is not NULL
  388.      before dereferencing it.
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  401.  
  402.  
  403.  
  404.      These two functions check if a hash table entry exists, and deletes it.
  405.  
  406.          bool  hv_exists(HV*, char* key, U32 klen);
  407.          SV*   hv_delete(HV*, char* key, U32 klen, I32 flags);
  408.  
  409.      If flags does not include the G_DISCARD flag then hv_delete will create
  410.      and return a mortal copy of the deleted value.
  411.  
  412.      And more miscellaneous functions:
  413.  
  414.          void   hv_clear(HV*);
  415.          void   hv_undef(HV*);
  416.  
  417.      Like their AV counterparts, hv_clear deletes all the entries in the hash
  418.      table but does not actually delete the hash table.  The hv_undef deletes
  419.      both the entries and the hash table itself.
  420.  
  421.      Perl keeps the actual data in linked list of structures with a typedef of
  422.      HE.  These contain the actual key and value pointers (plus extra
  423.      administrative overhead).  The key is a string pointer; the value is an
  424.      SV*.  However, once you have an HE*, to get the actual key and value, use
  425.      the routines specified below.
  426.  
  427.          I32    hv_iterinit(HV*);
  428.                  /* Prepares starting point to traverse hash table */
  429.          HE*    hv_iternext(HV*);
  430.                  /* Get the next entry, and return a pointer to a
  431.                     structure that has both the key and value */
  432.          char*  hv_iterkey(HE* entry, I32* retlen);
  433.                  /* Get the key from an HE structure and also return
  434.                     the length of the key string */
  435.          SV*    hv_iterval(HV*, HE* entry);
  436.                  /* Return a SV pointer to the value of the HE
  437.                     structure */
  438.          SV*    hv_iternextsv(HV*, char** key, I32* retlen);
  439.                  /* This convenience routine combines hv_iternext,
  440.                     hv_iterkey, and hv_iterval.  The key and retlen
  441.                     arguments are return values for the key and its
  442.                     length.  The value is returned in the SV* argument */
  443.  
  444.      If you know the name of a hash variable, you can get a pointer to its HV
  445.      by using the following:
  446.  
  447.          HV*  perl_get_hv("package::varname", FALSE);
  448.  
  449.      This returns NULL if the variable does not exist.
  450.  
  451.      The hash algorithm is defined in the PERL_HASH(hash, key, klen) macro:
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  467.  
  468.  
  469.  
  470.          i = klen;
  471.          hash = 0;
  472.          s = key;
  473.          while (i--)
  474.              hash = hash * 33 + *s++;
  475.  
  476.      See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d _A_r_r_a_y_s for
  477.      more information on how to use the hash access functions on tied hashes.
  478.  
  479.      HHHHaaaasssshhhh AAAAPPPPIIII EEEExxxxtttteeeennnnssssiiiioooonnnnssss
  480.  
  481.      Beginning with version 5.004, the following functions are also supported:
  482.  
  483.          HE*     hv_fetch_ent  (HV* tb, SV* key, I32 lval, U32 hash);
  484.          HE*     hv_store_ent  (HV* tb, SV* key, SV* val, U32 hash);
  485.  
  486.          bool    hv_exists_ent (HV* tb, SV* key, U32 hash);
  487.          SV*     hv_delete_ent (HV* tb, SV* key, I32 flags, U32 hash);
  488.  
  489.          SV*     hv_iterkeysv  (HE* entry);
  490.  
  491.      Note that these functions take SV* keys, which simplifies writing of
  492.      extension code that deals with hash structures.  These functions also
  493.      allow passing of SV* keys to tie functions without forcing you to
  494.      stringify the keys (unlike the previous set of functions).
  495.  
  496.      They also return and accept whole hash entries (HE*), making their use
  497.      more efficient (since the hash number for a particular string doesn't
  498.      have to be recomputed every time).  See the section on _A_P_I _L_I_S_T_I_N_G later
  499.      in this document for detailed descriptions.
  500.  
  501.      The following macros must always be used to access the contents of hash
  502.      entries.  Note that the arguments to these macros must be simple
  503.      variables, since they may get evaluated more than once.  See the section
  504.      on _A_P_I _L_I_S_T_I_N_G later in this document for detailed descriptions of these
  505.      macros.
  506.  
  507.          HePV(HE* he, STRLEN len)
  508.          HeVAL(HE* he)
  509.          HeHASH(HE* he)
  510.          HeSVKEY(HE* he)
  511.          HeSVKEY_force(HE* he)
  512.          HeSVKEY_set(HE* he, SV* sv)
  513.  
  514.      These two lower level macros are defined, but must only be used when
  515.      dealing with keys that are not SV*s:
  516.  
  517.          HeKEY(HE* he)
  518.          HeKLEN(HE* he)
  519.  
  520.      Note that both hv_store and hv_store_ent do not increment the reference
  521.      count of the stored val, which is the caller's responsibility.  If these
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  533.  
  534.  
  535.  
  536.      functions return a NULL value, the caller will usually have to decrement
  537.      the reference count of val to avoid a memory leak.
  538.  
  539.      RRRReeeeffffeeeerrrreeeennnncccceeeessss
  540.  
  541.      References are a special type of scalar that point to other data types
  542.      (including references).
  543.  
  544.      To create a reference, use either of the following functions:
  545.  
  546.          SV* newRV_inc((SV*) thing);
  547.          SV* newRV_noinc((SV*) thing);
  548.  
  549.      The thing argument can be any of an SV*, AV*, or HV*.  The functions are
  550.      identical except that newRV_inc increments the reference count of the
  551.      thing, while newRV_noinc does not.  For historical reasons, newRV is a
  552.      synonym for newRV_inc.
  553.  
  554.      Once you have a reference, you can use the following macro to dereference
  555.      the reference:
  556.  
  557.          SvRV(SV*)
  558.  
  559.      then call the appropriate routines, casting the returned SV* to either an
  560.      AV* or HV*, if required.
  561.  
  562.      To determine if an SV is a reference, you can use the following macro:
  563.  
  564.          SvROK(SV*)
  565.  
  566.      To discover what type of value the reference refers to, use the following
  567.      macro and then check the return value.
  568.  
  569.          SvTYPE(SvRV(SV*))
  570.  
  571.      The most useful types that will be returned are:
  572.  
  573.          SVt_IV    Scalar
  574.          SVt_NV    Scalar
  575.          SVt_PV    Scalar
  576.          SVt_RV    Scalar
  577.          SVt_PVAV  Array
  578.          SVt_PVHV  Hash
  579.          SVt_PVCV  Code
  580.          SVt_PVGV  Glob (possible a file handle)
  581.          SVt_PVMG  Blessed or Magical Scalar
  582.  
  583.          See the sv.h header file for more details.
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  599.  
  600.  
  601.  
  602.      BBBBlllleeeesssssssseeeedddd RRRReeeeffffeeeerrrreeeennnncccceeeessss aaaannnndddd CCCCllllaaaassssssss OOOObbbbjjjjeeeeccccttttssss
  603.  
  604.      References are also used to support object-oriented programming.  In the
  605.      OO lexicon, an object is simply a reference that has been blessed into a
  606.      package (or class).  Once blessed, the programmer may now use the
  607.      reference to access the various methods in the class.
  608.  
  609.      A reference can be blessed into a package with the following function:
  610.  
  611.          SV* sv_bless(SV* sv, HV* stash);
  612.  
  613.      The sv argument must be a reference.  The stash argument specifies which
  614.      class the reference will belong to.  See the section on _S_t_a_s_h_e_s _a_n_d _G_l_o_b_s
  615.      for information on converting class names into stashes.
  616.  
  617.      /* Still under construction */
  618.  
  619.      Upgrades rv to reference if not already one.  Creates new SV for rv to
  620.      point to.  If classname is non-null, the SV is blessed into the specified
  621.      class.  SV is returned.
  622.  
  623.              SV* newSVrv(SV* rv, char* classname);
  624.  
  625.      Copies integer or double into an SV whose reference is rv.  SV is blessed
  626.      if classname is non-null.
  627.  
  628.              SV* sv_setref_iv(SV* rv, char* classname, IV iv);
  629.              SV* sv_setref_nv(SV* rv, char* classname, NV iv);
  630.  
  631.      Copies the pointer value (_t_h_e _a_d_d_r_e_s_s, _n_o_t _t_h_e _s_t_r_i_n_g!) into an SV whose
  632.      reference is rv.  SV is blessed if classname is non-null.
  633.  
  634.              SV* sv_setref_pv(SV* rv, char* classname, PV iv);
  635.  
  636.      Copies string into an SV whose reference is rv.  Set length to 0 to let
  637.      Perl calculate the string length.  SV is blessed if classname is non-
  638.      null.
  639.  
  640.              SV* sv_setref_pvn(SV* rv, char* classname, PV iv, int length);
  641.  
  642.      Tests whether the SV is blessed into the specified class.  It does not
  643.      check inheritance relationships.
  644.  
  645.              int  sv_isa(SV* sv, char* name);
  646.  
  647.      Tests whether the SV is a reference to a blessed object.
  648.  
  649.              int  sv_isobject(SV* sv);
  650.  
  651.      Tests whether the SV is derived from the specified class. SV can be
  652.      either a reference to a blessed object or a string containing a class
  653.      name. This is the function implementing the UNIVERSAL::isa functionality.
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  665.  
  666.  
  667.  
  668.              bool sv_derived_from(SV* sv, char* name);
  669.  
  670.      To check if you've got an object derived from a specific class you have
  671.      to write:
  672.  
  673.              if (sv_isobject(sv) && sv_derived_from(sv, class)) { ... }
  674.  
  675.  
  676.      CCCCrrrreeeeaaaattttiiiinnnngggg NNNNeeeewwww VVVVaaaarrrriiiiaaaabbbblllleeeessss
  677.  
  678.      To create a new Perl variable with an undef value which can be accessed
  679.      from your Perl script, use the following routines, depending on the
  680.      variable type.
  681.  
  682.          SV*  perl_get_sv("package::varname", TRUE);
  683.          AV*  perl_get_av("package::varname", TRUE);
  684.          HV*  perl_get_hv("package::varname", TRUE);
  685.  
  686.      Notice the use of TRUE as the second parameter.  The new variable can now
  687.      be set, using the routines appropriate to the data type.
  688.  
  689.      There are additional macros whose values may be bitwise OR'ed with the
  690.      TRUE argument to enable certain extra features.  Those bits are:
  691.  
  692.          GV_ADDMULTI Marks the variable as multiply defined, thus preventing the
  693.                      "Name <varname> used only once: possible typo" warning.
  694.          GV_ADDWARN  Issues the warning "Had to create <varname> unexpectedly" if
  695.                      the variable did not exist before the function was called.
  696.  
  697.      If you do not specify a package name, the variable is created in the
  698.      current package.
  699.  
  700.      RRRReeeeffffeeeerrrreeeennnncccceeee CCCCoooouuuunnnnttttssss aaaannnndddd MMMMoooorrrrttttaaaalllliiiittttyyyy
  701.  
  702.      Perl uses an reference count-driven garbage collection mechanism. SVs,
  703.      AVs, or HVs (xV for short in the following) start their life with a
  704.      reference count of 1.  If the reference count of an xV ever drops to 0,
  705.      then it will be destroyed and its memory made available for reuse.
  706.  
  707.      This normally doesn't happen at the Perl level unless a variable is
  708.      undef'ed or the last variable holding a reference to it is changed or
  709.      overwritten.  At the internal level, however, reference counts can be
  710.      manipulated with the following macros:
  711.  
  712.          int SvREFCNT(SV* sv);
  713.          SV* SvREFCNT_inc(SV* sv);
  714.          void SvREFCNT_dec(SV* sv);
  715.  
  716.      However, there is one other function which manipulates the reference
  717.      count of its argument.  The newRV_inc function, you will recall, creates
  718.      a reference to the specified argument.  As a side effect, it increments
  719.      the argument's reference count.  If this is not what you want, use
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  731.  
  732.  
  733.  
  734.      newRV_noinc instead.
  735.  
  736.      For example, imagine you want to return a reference from an XSUB
  737.      function.  Inside the XSUB routine, you create an SV which initially has
  738.      a reference count of one.  Then you call newRV_inc, passing it the just-
  739.      created SV.  This returns the reference as a new SV, but the reference
  740.      count of the SV you passed to newRV_inc has been incremented to two.  Now
  741.      you return the reference from the XSUB routine and forget about the SV.
  742.      But Perl hasn't!  Whenever the returned reference is destroyed, the
  743.      reference count of the original SV is decreased to one and nothing
  744.      happens.  The SV will hang around without any way to access it until Perl
  745.      itself terminates.  This is a memory leak.
  746.  
  747.      The correct procedure, then, is to use newRV_noinc instead of newRV_inc.
  748.      Then, if and when the last reference is destroyed, the reference count of
  749.      the SV will go to zero and it will be destroyed, stopping any memory
  750.      leak.
  751.  
  752.      There are some convenience functions available that can help with the
  753.      destruction of xVs.  These functions introduce the concept of
  754.      "mortality".  An xV that is mortal has had its reference count marked to
  755.      be decremented, but not actually decremented, until "a short time later".
  756.      Generally the term "short time later" means a single Perl statement, such
  757.      as a call to an XSUB function.  The actual determinant for when mortal
  758.      xVs have their reference count decremented depends on two macros,
  759.      SAVETMPS and FREETMPS.  See the _p_e_r_l_c_a_l_l manpage and the _p_e_r_l_x_s manpage
  760.      for more details on these macros.
  761.  
  762.      "Mortalization" then is at its simplest a deferred SvREFCNT_dec.
  763.      However, if you mortalize a variable twice, the reference count will
  764.      later be decremented twice.
  765.  
  766.      You should be careful about creating mortal variables.  Strange things
  767.      can happen if you make the same value mortal within multiple contexts, or
  768.      if you make a variable mortal multiple times.
  769.  
  770.      To create a mortal variable, use the functions:
  771.  
  772.          SV*  sv_newmortal()
  773.          SV*  sv_2mortal(SV*)
  774.          SV*  sv_mortalcopy(SV*)
  775.  
  776.      The first call creates a mortal SV, the second converts an existing SV to
  777.      a mortal SV (and thus defers a call to SvREFCNT_dec), and the third
  778.      creates a mortal copy of an existing SV.
  779.  
  780.      The mortal routines are not just for SVs -- AVs and HVs can be made
  781.      mortal by passing their address (type-casted to SV*) to the sv_2mortal or
  782.      sv_mortalcopy routines.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  797.  
  798.  
  799.  
  800.      SSSSttttaaaasssshhhheeeessss aaaannnndddd GGGGlllloooobbbbssss
  801.  
  802.      A "stash" is a hash that contains all of the different objects that are
  803.      contained within a package.  Each key of the stash is a symbol name
  804.      (shared by all the different types of objects that have the same name),
  805.      and each value in the hash table is a GV (Glob Value).  This GV in turn
  806.      contains references to the various objects of that name, including (but
  807.      not limited to) the following:
  808.  
  809.          Scalar Value
  810.          Array Value
  811.          Hash Value
  812.          I/O Handle
  813.          Format
  814.          Subroutine
  815.  
  816.      There is a single stash called "PL_defstash" that holds the items that
  817.      exist in the "main" package.  To get at the items in other packages,
  818.      append the string "::" to the package name.  The items in the "Foo"
  819.      package are in the stash "Foo::" in PL_defstash.  The items in the
  820.      "Bar::Baz" package are in the stash "Baz::" in "Bar::"'s stash.
  821.  
  822.      To get the stash pointer for a particular package, use the function:
  823.  
  824.          HV*  gv_stashpv(char* name, I32 create)
  825.          HV*  gv_stashsv(SV*, I32 create)
  826.  
  827.      The first function takes a literal string, the second uses the string
  828.      stored in the SV.  Remember that a stash is just a hash table, so you get
  829.      back an HV*.  The create flag will create a new package if it is set.
  830.  
  831.      The name that gv_stash*v wants is the name of the package whose symbol
  832.      table you want.  The default package is called main.  If you have
  833.      multiply nested packages, pass their names to gv_stash*v, separated by ::
  834.      as in the Perl language itself.
  835.  
  836.      Alternately, if you have an SV that is a blessed reference, you can find
  837.      out the stash pointer by using:
  838.  
  839.          HV*  SvSTASH(SvRV(SV*));
  840.  
  841.      then use the following to get the package name itself:
  842.  
  843.          char*  HvNAME(HV* stash);
  844.  
  845.      If you need to bless or re-bless an object you can use the following
  846.      function:
  847.  
  848.          SV*  sv_bless(SV*, HV* stash)
  849.  
  850.      where the first argument, an SV*, must be a reference, and the second
  851.      argument is a stash.  The returned SV* can now be used in the same way as
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  863.  
  864.  
  865.  
  866.      any other SV.
  867.  
  868.      For more information on references and blessings, consult the _p_e_r_l_r_e_f
  869.      manpage.
  870.  
  871.      DDDDoooouuuubbbblllleeee----TTTTyyyyppppeeeedddd SSSSVVVVssss
  872.  
  873.      Scalar variables normally contain only one type of value, an integer,
  874.      double, pointer, or reference.  Perl will automatically convert the
  875.      actual scalar data from the stored type into the requested type.
  876.  
  877.      Some scalar variables contain more than one type of scalar data.  For
  878.      example, the variable $! contains either the numeric value of errno or
  879.      its string equivalent from either strerror or sys_errlist[].
  880.  
  881.      To force multiple data values into an SV, you must do two things: use the
  882.      sv_set*v routines to add the additional scalar type, then set a flag so
  883.      that Perl will believe it contains more than one type of data.  The four
  884.      macros to set the flags are:
  885.  
  886.              SvIOK_on
  887.              SvNOK_on
  888.              SvPOK_on
  889.              SvROK_on
  890.  
  891.      The particular macro you must use depends on which sv_set*v routine you
  892.      called first.  This is because every sv_set*v routine turns on only the
  893.      bit for the particular type of data being set, and turns off all the
  894.      rest.
  895.  
  896.      For example, to create a new Perl variable called "dberror" that contains
  897.      both the numeric and descriptive string error values, you could use the
  898.      following code:
  899.  
  900.          extern int  dberror;
  901.          extern char *dberror_list;
  902.  
  903.          SV* sv = perl_get_sv("dberror", TRUE);
  904.          sv_setiv(sv, (IV) dberror);
  905.          sv_setpv(sv, dberror_list[dberror]);
  906.          SvIOK_on(sv);
  907.  
  908.      If the order of sv_setiv and sv_setpv had been reversed, then the macro
  909.      SvPOK_on would need to be called instead of SvIOK_on.
  910.  
  911.      MMMMaaaaggggiiiicccc VVVVaaaarrrriiiiaaaabbbblllleeeessss
  912.  
  913.      [This section still under construction.  Ignore everything here.  Post no
  914.      bills.  Everything not permitted is forbidden.]
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  929.  
  930.  
  931.  
  932.      Any SV may be magical, that is, it has special features that a normal SV
  933.      does not have.  These features are stored in the SV structure in a linked
  934.      list of struct magic's, typedef'ed to MAGIC.
  935.  
  936.          struct magic {
  937.              MAGIC*      mg_moremagic;
  938.              MGVTBL*     mg_virtual;
  939.              U16         mg_private;
  940.              char        mg_type;
  941.              U8          mg_flags;
  942.              SV*         mg_obj;
  943.              char*       mg_ptr;
  944.              I32         mg_len;
  945.          };
  946.  
  947.      Note this is current as of patchlevel 0, and could change at any time.
  948.  
  949.      AAAAssssssssiiiiggggnnnniiiinnnngggg MMMMaaaaggggiiiicccc
  950.  
  951.      Perl adds magic to an SV using the sv_magic function:
  952.  
  953.          void sv_magic(SV* sv, SV* obj, int how, char* name, I32 namlen);
  954.  
  955.      The sv argument is a pointer to the SV that is to acquire a new magical
  956.      feature.
  957.  
  958.      If sv is not already magical, Perl uses the SvUPGRADE macro to set the
  959.      SVt_PVMG flag for the sv.  Perl then continues by adding it to the
  960.      beginning of the linked list of magical features.  Any prior entry of the
  961.      same type of magic is deleted.  Note that this can be overridden, and
  962.      multiple instances of the same type of magic can be associated with an
  963.      SV.
  964.  
  965.      The name and namlen arguments are used to associate a string with the
  966.      magic, typically the name of a variable. namlen is stored in the mg_len
  967.      field and if name is non-null and namlen >= 0 a malloc'd copy of the name
  968.      is stored in mg_ptr field.
  969.  
  970.      The sv_magic function uses how to determine which, if any, predefined
  971.      "Magic Virtual Table" should be assigned to the mg_virtual field.  See
  972.      the "Magic Virtual Table" section below.  The how argument is also stored
  973.      in the mg_type field.
  974.  
  975.      The obj argument is stored in the mg_obj field of the MAGIC structure.
  976.      If it is not the same as the sv argument, the reference count of the obj
  977.      object is incremented.  If it is the same, or if the how argument is "#",
  978.      or if it is a NULL pointer, then obj is merely stored, without the
  979.      reference count being incremented.
  980.  
  981.      There is also a function to add magic to an HV:
  982.  
  983.  
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  995.  
  996.  
  997.  
  998.          void hv_magic(HV *hv, GV *gv, int how);
  999.  
  1000.      This simply calls sv_magic and coerces the gv argument into an SV.
  1001.  
  1002.      To remove the magic from an SV, call the function sv_unmagic:
  1003.  
  1004.          void sv_unmagic(SV *sv, int type);
  1005.  
  1006.      The type argument should be equal to the how value when the SV was
  1007.      initially made magical.
  1008.  
  1009.      MMMMaaaaggggiiiicccc VVVViiiirrrrttttuuuuaaaallll TTTTaaaabbbblllleeeessss
  1010.  
  1011.      The mg_virtual field in the MAGIC structure is a pointer to a MGVTBL,
  1012.      which is a structure of function pointers and stands for "Magic Virtual
  1013.      Table" to handle the various operations that might be applied to that
  1014.      variable.
  1015.  
  1016.      The MGVTBL has five pointers to the following routine types:
  1017.  
  1018.          int  (*svt_get)(SV* sv, MAGIC* mg);
  1019.          int  (*svt_set)(SV* sv, MAGIC* mg);
  1020.          U32  (*svt_len)(SV* sv, MAGIC* mg);
  1021.          int  (*svt_clear)(SV* sv, MAGIC* mg);
  1022.          int  (*svt_free)(SV* sv, MAGIC* mg);
  1023.  
  1024.      This MGVTBL structure is set at compile-time in perl.h and there are
  1025.      currently 19 types (or 21 with overloading turned on).  These different
  1026.      structures contain pointers to various routines that perform additional
  1027.      actions depending on which function is being called.
  1028.  
  1029.          Function pointer    Action taken
  1030.          ----------------    ------------
  1031.          svt_get             Do something after the value of the SV is retrieved.
  1032.          svt_set             Do something after the SV is assigned a value.
  1033.          svt_len             Report on the SV's length.
  1034.          svt_clear           Clear something the SV represents.
  1035.          svt_free            Free any extra storage associated with the SV.
  1036.  
  1037.      For instance, the MGVTBL structure called vtbl_sv (which corresponds to
  1038.      an mg_type of '\0') contains:
  1039.  
  1040.          { magic_get, magic_set, magic_len, 0, 0 }
  1041.  
  1042.      Thus, when an SV is determined to be magical and of type '\0', if a get
  1043.      operation is being performed, the routine magic_get is called.  All the
  1044.      various routines for the various magical types begin with magic_.
  1045.  
  1046.      The current kinds of Magic Virtual Tables are:
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1061.  
  1062.  
  1063.  
  1064.          mg_type  MGVTBL              Type of magic
  1065.          -------  ------              ----------------------------
  1066.          \0       vtbl_sv             Special scalar variable
  1067.          A        vtbl_amagic         %OVERLOAD hash
  1068.          a        vtbl_amagicelem     %OVERLOAD hash element
  1069.          c        (none)              Holds overload table (AMT) on stash
  1070.          B        vtbl_bm             Boyer-Moore (fast string search)
  1071.          E        vtbl_env            %ENV hash
  1072.          e        vtbl_envelem        %ENV hash element
  1073.          f        vtbl_fm             Formline ('compiled' format)
  1074.          g        vtbl_mglob          m//g target / study()ed string
  1075.          I        vtbl_isa            @ISA array
  1076.          i        vtbl_isaelem        @ISA array element
  1077.          k        vtbl_nkeys          scalar(keys()) lvalue
  1078.          L        (none)              Debugger %_<filename
  1079.          l        vtbl_dbline         Debugger %_<filename element
  1080.          o        vtbl_collxfrm       Locale transformation
  1081.          P        vtbl_pack           Tied array or hash
  1082.          p        vtbl_packelem       Tied array or hash element
  1083.          q        vtbl_packelem       Tied scalar or handle
  1084.          S        vtbl_sig            %SIG hash
  1085.          s        vtbl_sigelem        %SIG hash element
  1086.          t        vtbl_taint          Taintedness
  1087.          U        vtbl_uvar           Available for use by extensions
  1088.          v        vtbl_vec            vec() lvalue
  1089.          x        vtbl_substr         substr() lvalue
  1090.          y        vtbl_defelem        Shadow "foreach" iterator variable /
  1091.                                        smart parameter vivification
  1092.          *        vtbl_glob           GV (typeglob)
  1093.          #        vtbl_arylen         Array length ($#ary)
  1094.          .        vtbl_pos            pos() lvalue
  1095.          ~        (none)              Available for use by extensions
  1096.  
  1097.      When an uppercase and lowercase letter both exist in the table, then the
  1098.      uppercase letter is used to represent some kind of composite type (a list
  1099.      or a hash), and the lowercase letter is used to represent an element of
  1100.      that composite type.
  1101.  
  1102.      The '~' and 'U' magic types are defined specifically for use by
  1103.      extensions and will not be used by perl itself.  Extensions can use '~'
  1104.      magic to 'attach' private information to variables (typically objects).
  1105.      This is especially useful because there is no way for normal perl code to
  1106.      corrupt this private information (unlike using extra elements of a hash
  1107.      object).
  1108.  
  1109.      Similarly, 'U' magic can be used much like _t_i_e() to call a C function any
  1110.      time a scalar's value is used or changed.  The MAGIC's mg_ptr field
  1111.      points to a ufuncs structure:
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1127.  
  1128.  
  1129.  
  1130.          struct ufuncs {
  1131.              I32 (*uf_val)(IV, SV*);
  1132.              I32 (*uf_set)(IV, SV*);
  1133.              IV uf_index;
  1134.          };
  1135.  
  1136.      When the SV is read from or written to, the uf_val or uf_set function
  1137.      will be called with uf_index as the first arg and a pointer to the SV as
  1138.      the second.  A simple example of how to add 'U' magic is shown below.
  1139.      Note that the ufuncs structure is copied by sv_magic, so you can safely
  1140.      allocate it on the stack.
  1141.  
  1142.          void
  1143.          Umagic(sv)
  1144.              SV *sv;
  1145.          PREINIT:
  1146.              struct ufuncs uf;
  1147.          CODE:
  1148.              uf.uf_val   = &my_get_fn;
  1149.              uf.uf_set   = &my_set_fn;
  1150.              uf.uf_index = 0;
  1151.              sv_magic(sv, 0, 'U', (char*)&uf, sizeof(uf));
  1152.  
  1153.      Note that because multiple extensions may be using '~' or 'U' magic, it
  1154.      is important for extensions to take extra care to avoid conflict.
  1155.      Typically only using the magic on objects blessed into the same class as
  1156.      the extension is sufficient.  For '~' magic, it may also be appropriate
  1157.      to add an I32 'signature' at the top of the private data area and check
  1158.      that.
  1159.  
  1160.      Also note that the sv_set*() and sv_cat*() functions described earlier do
  1161.      nnnnooootttt invoke 'set' magic on their targets.  This must be done by the user
  1162.      either by calling the SvSETMAGIC() macro after calling these functions,
  1163.      or by using one of the sv_set*_mg() or sv_cat*_mg() functions.
  1164.      Similarly, generic C code must call the SvGETMAGIC() macro to invoke any
  1165.      'get' magic if they use an SV obtained from external sources in functions
  1166.      that don't handle magic.  the section on _A_P_I _L_I_S_T_I_N_G later in this
  1167.      document identifies such functions.  For example, calls to the sv_cat*()
  1168.      functions typically need to be followed by SvSETMAGIC(), but they don't
  1169.      need a prior SvGETMAGIC() since their implementation handles 'get' magic.
  1170.  
  1171.      FFFFiiiinnnnddddiiiinnnngggg MMMMaaaaggggiiiicccc
  1172.  
  1173.          MAGIC* mg_find(SV*, int type); /* Finds the magic pointer of that type */
  1174.  
  1175.      This routine returns a pointer to the MAGIC structure stored in the SV.
  1176.      If the SV does not have that magical feature, NULL is returned.  Also, if
  1177.      the SV is not of type SVt_PVMG, Perl may core dump.
  1178.  
  1179.          int mg_copy(SV* sv, SV* nsv, char* key, STRLEN klen);
  1180.  
  1181.      This routine checks to see what types of magic sv has.  If the mg_type
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1193.  
  1194.  
  1195.  
  1196.      field is an uppercase letter, then the mg_obj is copied to nsv, but the
  1197.      mg_type field is changed to be the lowercase letter.
  1198.  
  1199.      UUUUnnnnddddeeeerrrrssssttttaaaannnnddddiiiinnnngggg tttthhhheeee MMMMaaaaggggiiiicccc ooooffff TTTTiiiieeeedddd HHHHaaaasssshhhheeeessss aaaannnndddd AAAArrrrrrrraaaayyyyssss
  1200.  
  1201.      Tied hashes and arrays are magical beasts of the 'P' magic type.
  1202.  
  1203.      WARNING: As of the 5.004 release, proper usage of the array and hash
  1204.      access functions requires understanding a few caveats.  Some of these
  1205.      caveats are actually considered bugs in the API, to be fixed in later
  1206.      releases, and are bracketed with [MAYCHANGE] below. If you find yourself
  1207.      actually applying such information in this section, be aware that the
  1208.      behavior may change in the future, umm, without warning.
  1209.  
  1210.      The perl tie function associates a variable with an object that
  1211.      implements the various GET, SET etc methods.  To perform the equivalent
  1212.      of the perl tie function from an XSUB, you must mimic this behaviour.
  1213.      The code below carries out the necessary steps - firstly it creates a new
  1214.      hash, and then creates a second hash which it blesses into the class
  1215.      which will implement the tie methods. Lastly it ties the two hashes
  1216.      together, and returns a reference to the new tied hash.  Note that the
  1217.      code below does NOT call the TIEHASH method in the MyTie class - see the
  1218.      section on _C_a_l_l_i_n_g _P_e_r_l _R_o_u_t_i_n_e_s _f_r_o_m _w_i_t_h_i_n _C _P_r_o_g_r_a_m_s for details on
  1219.      how to do this.
  1220.  
  1221.          SV*
  1222.          mytie()
  1223.          PREINIT:
  1224.              HV *hash;
  1225.              HV *stash;
  1226.              SV *tie;
  1227.          CODE:
  1228.              hash = newHV();
  1229.              tie = newRV_noinc((SV*)newHV());
  1230.              stash = gv_stashpv("MyTie", TRUE);
  1231.              sv_bless(tie, stash);
  1232.              hv_magic(hash, tie, 'P');
  1233.              RETVAL = newRV_noinc(hash);
  1234.          OUTPUT:
  1235.              RETVAL
  1236.  
  1237.      The av_store function, when given a tied array argument, merely copies
  1238.      the magic of the array onto the value to be "stored", using mg_copy.  It
  1239.      may also return NULL, indicating that the value did not actually need to
  1240.      be stored in the array.  [MAYCHANGE] After a call to av_store on a tied
  1241.      array, the caller will usually need to call mg_set(val) to actually
  1242.      invoke the perl level "STORE" method on the TIEARRAY object.  If av_store
  1243.      did return NULL, a call to SvREFCNT_dec(val) will also be usually
  1244.      necessary to avoid a memory leak. [/MAYCHANGE]
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1259.  
  1260.  
  1261.  
  1262.      The previous paragraph is applicable verbatim to tied hash access using
  1263.      the hv_store and hv_store_ent functions as well.
  1264.  
  1265.      av_fetch and the corresponding hash functions hv_fetch and hv_fetch_ent
  1266.      actually return an undefined mortal value whose magic has been
  1267.      initialized using mg_copy.  Note the value so returned does not need to
  1268.      be deallocated, as it is already mortal.  [MAYCHANGE] But you will need
  1269.      to call mg_get() on the returned value in order to actually invoke the
  1270.      perl level "FETCH" method on the underlying TIE object.  Similarly, you
  1271.      may also call mg_set() on the return value after possibly assigning a
  1272.      suitable value to it using sv_setsv,  which will invoke the "STORE"
  1273.      method on the TIE object. [/MAYCHANGE]
  1274.  
  1275.      [MAYCHANGE] In other words, the array or hash fetch/store functions don't
  1276.      really fetch and store actual values in the case of tied arrays and
  1277.      hashes.  They merely call mg_copy to attach magic to the values that were
  1278.      meant to be "stored" or "fetched".  Later calls to mg_get and mg_set
  1279.      actually do the job of invoking the TIE methods on the underlying
  1280.      objects.  Thus the magic mechanism currently implements a kind of lazy
  1281.      access to arrays and hashes.
  1282.  
  1283.      Currently (as of perl version 5.004), use of the hash and array access
  1284.      functions requires the user to be aware of whether they are operating on
  1285.      "normal" hashes and arrays, or on their tied variants.  The API may be
  1286.      changed to provide more transparent access to both tied and normal data
  1287.      types in future versions.  [/MAYCHANGE]
  1288.  
  1289.      You would do well to understand that the TIEARRAY and TIEHASH interfaces
  1290.      are mere sugar to invoke some perl method calls while using the uniform
  1291.      hash and array syntax.  The use of this sugar imposes some overhead
  1292.      (typically about two to four extra opcodes per FETCH/STORE operation, in
  1293.      addition to the creation of all the mortal variables required to invoke
  1294.      the methods).  This overhead will be comparatively small if the TIE
  1295.      methods are themselves substantial, but if they are only a few statements
  1296.      long, the overhead will not be insignificant.
  1297.  
  1298.      LLLLooooccccaaaalllliiiizzzziiiinnnngggg cccchhhhaaaannnnggggeeeessss
  1299.  
  1300.      Perl has a very handy construction
  1301.  
  1302.        {
  1303.          local $var = 2;
  1304.          ...
  1305.        }
  1306.  
  1307.      This construction is _a_p_p_r_o_x_i_m_a_t_e_l_y equivalent to
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                                                        PPPPaaaaggggeeee 22220000
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1325.  
  1326.  
  1327.  
  1328.        {
  1329.          my $oldvar = $var;
  1330.          $var = 2;
  1331.          ...
  1332.          $var = $oldvar;
  1333.        }
  1334.  
  1335.      The biggest difference is that the first construction would reinstate the
  1336.      initial value of $var, irrespective of how control exits the block: goto,
  1337.      return, die/eval etc. It is a little bit more efficient as well.
  1338.  
  1339.      There is a way to achieve a similar task from C via Perl API: create a
  1340.      _p_s_e_u_d_o-_b_l_o_c_k, and arrange for some changes to be automatically undone at
  1341.      the end of it, either explicit, or via a non-local exit (via _d_i_e()). A
  1342.      _b_l_o_c_k-like construct is created by a pair of ENTER/LEAVE macros (see the
  1343.      section on _R_e_t_u_r_n_i_n_g _a _S_c_a_l_a_r in the _p_e_r_l_c_a_l_l manpage).  Such a construct
  1344.      may be created specially for some important localized task, or an
  1345.      existing one (like boundaries of enclosing Perl subroutine/block, or an
  1346.      existing pair for freeing TMPs) may be used. (In the second case the
  1347.      overhead of additional localization must be almost negligible.) Note that
  1348.      any XSUB is automatically enclosed in an ENTER/LEAVE pair.
  1349.  
  1350.      Inside such a _p_s_e_u_d_o-_b_l_o_c_k the following service is available:
  1351.  
  1352.      SAVEINT(int i)
  1353.  
  1354.      SAVEIV(IV i)
  1355.  
  1356.      SAVEI32(I32 i)
  1357.  
  1358.      SAVELONG(long i)
  1359.           These macros arrange things to restore the value of integer variable
  1360.           i at the end of enclosing _p_s_e_u_d_o-_b_l_o_c_k.
  1361.  
  1362.      SAVESPTR(s)
  1363.  
  1364.      SAVEPPTR(p)
  1365.           These macros arrange things to restore the value of pointers s and
  1366.           p. s must be a pointer of a type which survives conversion to SV*
  1367.           and back, p should be able to survive conversion to char* and back.
  1368.  
  1369.      SAVEFREESV(SV *sv)
  1370.           The refcount of sv would be decremented at the end of _p_s_e_u_d_o-_b_l_o_c_k.
  1371.           This is similar to sv_2mortal, which should (?) be used instead.
  1372.  
  1373.      SAVEFREEOP(OP *op)
  1374.           The OP * is _o_p__f_r_e_e()ed at the end of _p_s_e_u_d_o-_b_l_o_c_k.
  1375.  
  1376.      SAVEFREEPV(p)
  1377.           The chunk of memory which is pointed to by p is _S_a_f_e_f_r_e_e()ed at the
  1378.           end of _p_s_e_u_d_o-_b_l_o_c_k.
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                                                        PPPPaaaaggggeeee 22221111
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1391.  
  1392.  
  1393.  
  1394.      SAVECLEARSV(SV *sv)
  1395.           Clears a slot in the current scratchpad which corresponds to sv at
  1396.           the end of _p_s_e_u_d_o-_b_l_o_c_k.
  1397.  
  1398.      SAVEDELETE(HV *hv, char *key, I32 length)
  1399.           The key key of hv is deleted at the end of _p_s_e_u_d_o-_b_l_o_c_k. The string
  1400.           pointed to by key is _S_a_f_e_f_r_e_e()ed.  If one has a _k_e_y in short-lived
  1401.           storage, the corresponding string may be reallocated like this:
  1402.  
  1403.             SAVEDELETE(PL_defstash, savepv(tmpbuf), strlen(tmpbuf));
  1404.  
  1405.  
  1406.      SAVEDESTRUCTOR(f,p)
  1407.           At the end of _p_s_e_u_d_o-_b_l_o_c_k the function f is called with the only
  1408.           argument (of type void*) p.
  1409.  
  1410.      SAVESTACK_POS()
  1411.           The current offset on the Perl internal stack (cf. SP) is restored
  1412.           at the end of _p_s_e_u_d_o-_b_l_o_c_k.
  1413.  
  1414.      The following API list contains functions, thus one needs to provide
  1415.      pointers to the modifiable data explicitly (either C pointers, or Perlish
  1416.      GV *s).  Where the above macros take int, a similar function takes int *.
  1417.  
  1418.      SV* save_scalar(GV *gv)
  1419.           Equivalent to Perl code local $gv.
  1420.  
  1421.      AV* save_ary(GV *gv)
  1422.  
  1423.      HV* save_hash(GV *gv)
  1424.           Similar to save_scalar, but localize @gv and %gv.
  1425.  
  1426.      void save_item(SV *item)
  1427.           Duplicates the current value of SV, on the exit from the current
  1428.           ENTER/LEAVE _p_s_e_u_d_o-_b_l_o_c_k will restore the value of SV using the
  1429.           stored value.
  1430.  
  1431.      void save_list(SV **sarg, I32 maxsarg)
  1432.           A variant of save_item which takes multiple arguments via an array
  1433.           sarg of SV* of length maxsarg.
  1434.  
  1435.      SV* save_svref(SV **sptr)
  1436.           Similar to save_scalar, but will reinstate a SV *.
  1437.  
  1438.      void save_aptr(AV **aptr)
  1439.  
  1440.      void save_hptr(HV **hptr)
  1441.           Similar to save_svref, but localize AV * and HV *.
  1442.  
  1443.      The Alias module implements localization of the basic types within the
  1444.      _c_a_l_l_e_r'_s _s_c_o_p_e.  People who are interested in how to localize things in
  1445.      the containing scope should take a look there too.
  1446.  
  1447.  
  1448.  
  1449.                                                                        PPPPaaaaggggeeee 22222222
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1457.  
  1458.  
  1459.  
  1460. SSSSuuuubbbbrrrroooouuuuttttiiiinnnneeeessss
  1461.      XXXXSSSSUUUUBBBBssss aaaannnndddd tttthhhheeee AAAArrrrgggguuuummmmeeeennnntttt SSSSttttaaaacccckkkk
  1462.  
  1463.      The XSUB mechanism is a simple way for Perl programs to access C
  1464.      subroutines.  An XSUB routine will have a stack that contains the
  1465.      arguments from the Perl program, and a way to map from the Perl data
  1466.      structures to a C equivalent.
  1467.  
  1468.      The stack arguments are accessible through the ST(n) macro, which returns
  1469.      the n'th stack argument.  Argument 0 is the first argument passed in the
  1470.      Perl subroutine call.  These arguments are SV*, and can be used anywhere
  1471.      an SV* is used.
  1472.  
  1473.      Most of the time, output from the C routine can be handled through use of
  1474.      the RETVAL and OUTPUT directives.  However, there are some cases where
  1475.      the argument stack is not already long enough to handle all the return
  1476.      values.  An example is the POSIX _t_z_n_a_m_e() call, which takes no arguments,
  1477.      but returns two, the local time zone's standard and summer time
  1478.      abbreviations.
  1479.  
  1480.      To handle this situation, the PPCODE directive is used and the stack is
  1481.      extended using the macro:
  1482.  
  1483.          EXTEND(SP, num);
  1484.  
  1485.      where SP is the macro that represents the local copy of the stack
  1486.      pointer, and num is the number of elements the stack should be extended
  1487.      by.
  1488.  
  1489.      Now that there is room on the stack, values can be pushed on it using the
  1490.      macros to push IVs, doubles, strings, and SV pointers respectively:
  1491.  
  1492.          PUSHi(IV)
  1493.          PUSHn(double)
  1494.          PUSHp(char*, I32)
  1495.          PUSHs(SV*)
  1496.  
  1497.      And now the Perl program calling tzname, the two values will be assigned
  1498.      as in:
  1499.  
  1500.          ($standard_abbrev, $summer_abbrev) = POSIX::tzname;
  1501.  
  1502.      An alternate (and possibly simpler) method to pushing values on the stack
  1503.      is to use the macros:
  1504.  
  1505.          XPUSHi(IV)
  1506.          XPUSHn(double)
  1507.          XPUSHp(char*, I32)
  1508.          XPUSHs(SV*)
  1509.  
  1510.      These macros automatically adjust the stack for you, if needed.  Thus,
  1511.      you do not need to call EXTEND to extend the stack.
  1512.  
  1513.  
  1514.  
  1515.                                                                        PPPPaaaaggggeeee 22223333
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1523.  
  1524.  
  1525.  
  1526.      For more information, consult the _p_e_r_l_x_s manpage and the _p_e_r_l_x_s_t_u_t
  1527.      manpage.
  1528.  
  1529.      CCCCaaaalllllllliiiinnnngggg PPPPeeeerrrrllll RRRRoooouuuuttttiiiinnnneeeessss ffffrrrroooommmm wwwwiiiitttthhhhiiiinnnn CCCC PPPPrrrrooooggggrrrraaaammmmssss
  1530.  
  1531.      There are four routines that can be used to call a Perl subroutine from
  1532.      within a C program.  These four are:
  1533.  
  1534.          I32  perl_call_sv(SV*, I32);
  1535.          I32  perl_call_pv(char*, I32);
  1536.          I32  perl_call_method(char*, I32);
  1537.          I32  perl_call_argv(char*, I32, register char**);
  1538.  
  1539.      The routine most often used is perl_call_sv.  The SV* argument contains
  1540.      either the name of the Perl subroutine to be called, or a reference to
  1541.      the subroutine.  The second argument consists of flags that control the
  1542.      context in which the subroutine is called, whether or not the subroutine
  1543.      is being passed arguments, how errors should be trapped, and how to treat
  1544.      return values.
  1545.  
  1546.      All four routines return the number of arguments that the subroutine
  1547.      returned on the Perl stack.
  1548.  
  1549.      When using any of these routines (except perl_call_argv), the programmer
  1550.      must manipulate the Perl stack.  These include the following macros and
  1551.      functions:
  1552.  
  1553.          dSP
  1554.          SP
  1555.          PUSHMARK()
  1556.          PUTBACK
  1557.          SPAGAIN
  1558.          ENTER
  1559.          SAVETMPS
  1560.          FREETMPS
  1561.          LEAVE
  1562.          XPUSH*()
  1563.          POP*()
  1564.  
  1565.      For a detailed description of calling conventions from C to Perl, consult
  1566.      the _p_e_r_l_c_a_l_l manpage.
  1567.  
  1568.      MMMMeeeemmmmoooorrrryyyy AAAAllllllllooooccccaaaattttiiiioooonnnn
  1569.  
  1570.      It is suggested that you use the version of malloc that is distributed
  1571.      with Perl.  It keeps pools of various sizes of unallocated memory in
  1572.      order to satisfy allocation requests more quickly.  However, on some
  1573.      platforms, it may cause spurious malloc or free errors.
  1574.  
  1575.          New(x, pointer, number, type);
  1576.          Newc(x, pointer, number, type, cast);
  1577.          Newz(x, pointer, number, type);
  1578.  
  1579.  
  1580.  
  1581.                                                                        PPPPaaaaggggeeee 22224444
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1589.  
  1590.  
  1591.  
  1592.      These three macros are used to initially allocate memory.
  1593.  
  1594.      The first argument x was a "magic cookie" that was used to keep track of
  1595.      who called the macro, to help when debugging memory problems.  However,
  1596.      the current code makes no use of this feature (most Perl developers now
  1597.      use run-time memory checkers), so this argument can be any number.
  1598.  
  1599.      The second argument pointer should be the name of a variable that will
  1600.      point to the newly allocated memory.
  1601.  
  1602.      The third and fourth arguments number and type specify how many of the
  1603.      specified type of data structure should be allocated.  The argument type
  1604.      is passed to sizeof.  The final argument to Newc, cast, should be used if
  1605.      the pointer argument is different from the type argument.
  1606.  
  1607.      Unlike the New and Newc macros, the Newz macro calls memzero to zero out
  1608.      all the newly allocated memory.
  1609.  
  1610.          Renew(pointer, number, type);
  1611.          Renewc(pointer, number, type, cast);
  1612.          Safefree(pointer)
  1613.  
  1614.      These three macros are used to change a memory buffer size or to free a
  1615.      piece of memory no longer needed.  The arguments to Renew and Renewc
  1616.      match those of New and Newc with the exception of not needing the "magic
  1617.      cookie" argument.
  1618.  
  1619.          Move(source, dest, number, type);
  1620.          Copy(source, dest, number, type);
  1621.          Zero(dest, number, type);
  1622.  
  1623.      These three macros are used to move, copy, or zero out previously
  1624.      allocated memory.  The source and dest arguments point to the source and
  1625.      destination starting points.  Perl will move, copy, or zero out number
  1626.      instances of the size of the type data structure (using the sizeof
  1627.      function).
  1628.  
  1629.      PPPPeeeerrrrllllIIIIOOOO
  1630.  
  1631.      The most recent development releases of Perl has been experimenting with
  1632.      removing Perl's dependency on the "normal" standard I/O suite and
  1633.      allowing other stdio implementations to be used.  This involves creating
  1634.      a new abstraction layer that then calls whichever implementation of stdio
  1635.      Perl was compiled with.  All XSUBs should now use the functions in the
  1636.      PerlIO abstraction layer and not make any assumptions about what kind of
  1637.      stdio is being used.
  1638.  
  1639.      For a complete description of the PerlIO abstraction, consult the
  1640.      _p_e_r_l_a_p_i_o manpage.
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                                                        PPPPaaaaggggeeee 22225555
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1655.  
  1656.  
  1657.  
  1658.      PPPPuuuuttttttttiiiinnnngggg aaaa CCCC vvvvaaaalllluuuueeee oooonnnn PPPPeeeerrrrllll ssssttttaaaacccckkkk
  1659.  
  1660.      A lot of opcodes (this is an elementary operation in the internal perl
  1661.      stack machine) put an SV* on the stack. However, as an optimization the
  1662.      corresponding SV is (usually) not recreated each time. The opcodes reuse
  1663.      specially assigned SVs (_t_a_r_g_e_ts) which are (as a corollary) not
  1664.      constantly freed/created.
  1665.  
  1666.      Each of the targets is created only once (but see the section on
  1667.      _S_c_r_a_t_c_h_p_a_d_s _a_n_d _r_e_c_u_r_s_i_o_n below), and when an opcode needs to put an
  1668.      integer, a double, or a string on stack, it just sets the corresponding
  1669.      parts of its _t_a_r_g_e_t and puts the _t_a_r_g_e_t on stack.
  1670.  
  1671.      The macro to put this target on stack is PUSHTARG, and it is directly
  1672.      used in some opcodes, as well as indirectly in zillions of others, which
  1673.      use it via (X)PUSH[pni].
  1674.  
  1675.      SSSSccccrrrraaaattttcccchhhhppppaaaaddddssss
  1676.  
  1677.      The question remains on when the SVs which are _t_a_r_g_e_ts for opcodes are
  1678.      created. The answer is that they are created when the current unit -- a
  1679.      subroutine or a file (for opcodes for statements outside of subroutines)
  1680.      -- is compiled. During this time a special anonymous Perl array is
  1681.      created, which is called a scratchpad for the current unit.
  1682.  
  1683.      A scratchpad keeps SVs which are lexicals for the current unit and are
  1684.      targets for opcodes. One can deduce that an SV lives on a scratchpad by
  1685.      looking on its flags: lexicals have SVs_PADMY set, and _t_a_r_g_e_ts have
  1686.      SVs_PADTMP set.
  1687.  
  1688.      The correspondence between OPs and _t_a_r_g_e_ts is not 1-to-1. Different OPs
  1689.      in the compile tree of the unit can use the same target, if this would
  1690.      not conflict with the expected life of the temporary.
  1691.  
  1692.      SSSSccccrrrraaaattttcccchhhhppppaaaaddddssss aaaannnndddd rrrreeeeccccuuuurrrrssssiiiioooonnnn
  1693.  
  1694.      In fact it is not 100% true that a compiled unit contains a pointer to
  1695.      the scratchpad AV. In fact it contains a pointer to an AV of (initially)
  1696.      one element, and this element is the scratchpad AV. Why do we need an
  1697.      extra level of indirection?
  1698.  
  1699.      The answer is rrrreeeeccccuuuurrrrssssiiiioooonnnn, and maybe (sometime soon) tttthhhhrrrreeeeaaaaddddssss. Both these
  1700.      can create several execution pointers going into the same subroutine. For
  1701.      the subroutine-child not write over the temporaries for the subroutine-
  1702.      parent (lifespan of which covers the call to the child), the parent and
  1703.      the child should have different scratchpads. (_A_n_d the lexicals should be
  1704.      separate anyway!)
  1705.  
  1706.      So each subroutine is born with an array of scratchpads (of length 1).
  1707.      On each entry to the subroutine it is checked that the current depth of
  1708.      the recursion is not more than the length of this array, and if it is,
  1709.      new scratchpad is created and pushed into the array.
  1710.  
  1711.  
  1712.  
  1713.                                                                        PPPPaaaaggggeeee 22226666
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1721.  
  1722.  
  1723.  
  1724.      The _t_a_r_g_e_ts on this scratchpad are undefs, but they are already marked
  1725.      with correct flags.
  1726.  
  1727. CCCCoooommmmppppiiiilllleeeedddd ccccooooddddeeee
  1728.      CCCCooooddddeeee ttttrrrreeeeeeee
  1729.  
  1730.      Here we describe the internal form your code is converted to by Perl.
  1731.      Start with a simple example:
  1732.  
  1733.        $a = $b + $c;
  1734.  
  1735.      This is converted to a tree similar to this one:
  1736.  
  1737.                   assign-to
  1738.                 /           \
  1739.                +             $a
  1740.              /   \
  1741.            $b     $c
  1742.  
  1743.      (but slightly more complicated).  This tree reflects the way Perl parsed
  1744.      your code, but has nothing to do with the execution order.  There is an
  1745.      additional "thread" going through the nodes of the tree which shows the
  1746.      order of execution of the nodes.  In our simplified example above it
  1747.      looks like:
  1748.  
  1749.           $b ---> $c ---> + ---> $a ---> assign-to
  1750.  
  1751.      But with the actual compile tree for $a = $b + $c it is different:  some
  1752.      nodes _o_p_t_i_m_i_z_e_d _a_w_a_y.  As a corollary, though the actual tree contains
  1753.      more nodes than our simplified example, the execution order is the same
  1754.      as in our example.
  1755.  
  1756.      EEEExxxxaaaammmmiiiinnnniiiinnnngggg tttthhhheeee ttttrrrreeeeeeee
  1757.  
  1758.      If you have your perl compiled for debugging (usually done with -D
  1759.      optimize=-g on Configure command line), you may examine the compiled tree
  1760.      by specifying -Dx on the Perl command line.  The output takes several
  1761.      lines per node, and for $b+$c it looks like this:
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.                                                                        PPPPaaaaggggeeee 22227777
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1787.  
  1788.  
  1789.  
  1790.          5           TYPE = add  ===> 6
  1791.                      TARG = 1
  1792.                      FLAGS = (SCALAR,KIDS)
  1793.                      {
  1794.                          TYPE = null  ===> (4)
  1795.                            (was rv2sv)
  1796.                          FLAGS = (SCALAR,KIDS)
  1797.                          {
  1798.          3                   TYPE = gvsv  ===> 4
  1799.                              FLAGS = (SCALAR)
  1800.                              GV = main::b
  1801.                          }
  1802.                      }
  1803.                      {
  1804.                          TYPE = null  ===> (5)
  1805.                            (was rv2sv)
  1806.                          FLAGS = (SCALAR,KIDS)
  1807.                          {
  1808.          4                   TYPE = gvsv  ===> 5
  1809.                              FLAGS = (SCALAR)
  1810.                              GV = main::c
  1811.                          }
  1812.                      }
  1813.  
  1814.      This tree has 5 nodes (one per TYPE specifier), only 3 of them are not
  1815.      optimized away (one per number in the left column).  The immediate
  1816.      children of the given node correspond to {} pairs on the same level of
  1817.      indentation, thus this listing corresponds to the tree:
  1818.  
  1819.                         add
  1820.                       /     \
  1821.                     null    null
  1822.                      |       |
  1823.                     gvsv    gvsv
  1824.  
  1825.      The execution order is indicated by ===> marks, thus it is 3 4 5 6 (node
  1826.      6 is not included into above listing), i.e., gvsv gvsv add whatever.
  1827.  
  1828.      CCCCoooommmmppppiiiilllleeee ppppaaaassssssss 1111:::: cccchhhheeeecccckkkk rrrroooouuuuttttiiiinnnneeeessss
  1829.  
  1830.      The tree is created by the _p_s_e_u_d_o-_c_o_m_p_i_l_e_r while yacc code feeds it the
  1831.      constructions it recognizes. Since yacc works bottom-up, so does the
  1832.      first pass of perl compilation.
  1833.  
  1834.      What makes this pass interesting for perl developers is that some
  1835.      optimization may be performed on this pass.  This is optimization by so-
  1836.      called _c_h_e_c_k _r_o_u_t_i_n_e_s.  The correspondence between node names and
  1837.      corresponding check routines is described in _o_p_c_o_d_e._p_l (do not forget to
  1838.      run make regen_headers if you modify this file).
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.                                                                        PPPPaaaaggggeeee 22228888
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1853.  
  1854.  
  1855.  
  1856.      A check routine is called when the node is fully constructed except for
  1857.      the execution-order thread.  Since at this time there are no back-links
  1858.      to the currently constructed node, one can do most any operation to the
  1859.      top-level node, including freeing it and/or creating new nodes
  1860.      above/below it.
  1861.  
  1862.      The check routine returns the node which should be inserted into the tree
  1863.      (if the top-level node was not modified, check routine returns its
  1864.      argument).
  1865.  
  1866.      By convention, check routines have names ck_*. They are usually called
  1867.      from new*OP subroutines (or convert) (which in turn are called from
  1868.      _p_e_r_l_y._y).
  1869.  
  1870.      CCCCoooommmmppppiiiilllleeee ppppaaaassssssss 1111aaaa:::: ccccoooonnnnssssttttaaaannnntttt ffffoooollllddddiiiinnnngggg
  1871.  
  1872.      Immediately after the check routine is called the returned node is
  1873.      checked for being compile-time executable.  If it is (the value is judged
  1874.      to be constant) it is immediately executed, and a _c_o_n_s_t_a_n_t node with the
  1875.      "return value" of the corresponding subtree is substituted instead.  The
  1876.      subtree is deleted.
  1877.  
  1878.      If constant folding was not performed, the execution-order thread is
  1879.      created.
  1880.  
  1881.      CCCCoooommmmppppiiiilllleeee ppppaaaassssssss 2222:::: ccccoooonnnntttteeeexxxxtttt pppprrrrooooppppaaaaggggaaaattttiiiioooonnnn
  1882.  
  1883.      When a context for a part of compile tree is known, it is propagated down
  1884.      through the tree.  At this time the context can have 5 values (instead of
  1885.      2 for runtime context): void, boolean, scalar, list, and lvalue.  In
  1886.      contrast with the pass 1 this pass is processed from top to bottom: a
  1887.      node's context determines the context for its children.
  1888.  
  1889.      Additional context-dependent optimizations are performed at this time.
  1890.      Since at this moment the compile tree contains back-references (via
  1891.      "thread" pointers), nodes cannot be _f_r_e_e()d now.  To allow optimized-away
  1892.      nodes at this stage, such nodes are _n_u_l_l()ified instead of _f_r_e_e()ing
  1893.      (i.e. their type is changed to OP_NULL).
  1894.  
  1895.      CCCCoooommmmppppiiiilllleeee ppppaaaassssssss 3333:::: ppppeeeeeeeepppphhhhoooolllleeee ooooppppttttiiiimmmmiiiizzzzaaaattttiiiioooonnnn
  1896.  
  1897.      After the compile tree for a subroutine (or for an eval or a file) is
  1898.      created, an additional pass over the code is performed. This pass is
  1899.      neither top-down or bottom-up, but in the execution order (with
  1900.      additional complications for conditionals).  These optimizations are done
  1901.      in the subroutine _p_e_e_p().  Optimizations performed at this stage are
  1902.      subject to the same restrictions as in the pass 2.
  1903.  
  1904. AAAAPPPPIIII LLLLIIIISSSSTTTTIIIINNNNGGGG
  1905.      This is a listing of functions, macros, flags, and variables that may be
  1906.      useful to extension writers or that may be found while reading other
  1907.      extensions.
  1908.  
  1909.  
  1910.  
  1911.                                                                        PPPPaaaaggggeeee 22229999
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1919.  
  1920.  
  1921.  
  1922.      Note that all Perl API global variables must be referenced with the PL_
  1923.      prefix.  Some macros are provided for compatibility with the older,
  1924.      unadorned names, but this support will be removed in a future release.
  1925.  
  1926.      It is strongly recommended that all Perl API functions that don't begin
  1927.      with perl be referenced with an explicit Perl_ prefix.
  1928.  
  1929.      The sort order of the listing is case insensitive, with any occurrences
  1930.      of '_' ignored for the the purpose of sorting.
  1931.  
  1932.      av_clear
  1933.              Clears an array, making it empty.  Does not free the memory used
  1934.              by the array itself.
  1935.  
  1936.                      void    av_clear (AV* ar)
  1937.  
  1938.  
  1939.      av_extend
  1940.              Pre-extend an array.  The key is the index to which the array
  1941.              should be extended.
  1942.  
  1943.                      void    av_extend (AV* ar, I32 key)
  1944.  
  1945.  
  1946.      av_fetch
  1947.              Returns the SV at the specified index in the array.  The key is
  1948.              the index.  If lval is set then the fetch will be part of a
  1949.              store.  Check that the return value is non-null before
  1950.              dereferencing it to a SV*.
  1951.  
  1952.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  1953.              _A_r_r_a_y_s for more information on how to use this function on tied
  1954.              arrays.
  1955.  
  1956.                      SV**    av_fetch (AV* ar, I32 key, I32 lval)
  1957.  
  1958.  
  1959.      AvFILL  Same as av_len().  Deprecated, use av_len() instead.
  1960.  
  1961.      av_len  Returns the highest index in the array.  Returns -1 if the array
  1962.              is empty.
  1963.  
  1964.                      I32     av_len (AV* ar)
  1965.  
  1966.  
  1967.      av_make Creates a new AV and populates it with a list of SVs.  The SVs
  1968.              are copied into the array, so they may be freed after the call to
  1969.              av_make.  The new AV will have a reference count of 1.
  1970.  
  1971.                      AV*     av_make (I32 size, SV** svp)
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.                                                                        PPPPaaaaggggeeee 33330000
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  1985.  
  1986.  
  1987.  
  1988.      av_pop  Pops an SV off the end of the array.  Returns &PL_sv_undef if the
  1989.              array is empty.
  1990.  
  1991.                      SV*     av_pop (AV* ar)
  1992.  
  1993.  
  1994.      av_push Pushes an SV onto the end of the array.  The array will grow
  1995.              automatically to accommodate the addition.
  1996.  
  1997.                      void    av_push (AV* ar, SV* val)
  1998.  
  1999.  
  2000.      av_shift
  2001.              Shifts an SV off the beginning of the array.
  2002.  
  2003.                      SV*     av_shift (AV* ar)
  2004.  
  2005.  
  2006.      av_store
  2007.              Stores an SV in an array.  The array index is specified as key.
  2008.              The return value will be NULL if the operation failed or if the
  2009.              value did not need to be actually stored within the array (as in
  2010.              the case of tied arrays).  Otherwise it can be dereferenced to
  2011.              get the original SV*.  Note that the caller is responsible for
  2012.              suitably incrementing the reference count of val before the call,
  2013.              and decrementing it if the function returned NULL.
  2014.  
  2015.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  2016.              _A_r_r_a_y_s for more information on how to use this function on tied
  2017.              arrays.
  2018.  
  2019.                      SV**    av_store (AV* ar, I32 key, SV* val)
  2020.  
  2021.  
  2022.      av_undef
  2023.              Undefines the array.  Frees the memory used by the array itself.
  2024.  
  2025.                      void    av_undef (AV* ar)
  2026.  
  2027.  
  2028.      av_unshift
  2029.              Unshift the given number of undef values onto the beginning of
  2030.              the array.  The array will grow automatically to accommodate the
  2031.              addition.  You must then use av_store to assign values to these
  2032.              new elements.
  2033.  
  2034.                      void    av_unshift (AV* ar, I32 num)
  2035.  
  2036.  
  2037.      CLASS   Variable which is setup by xsubpp to indicate the class name for
  2038.              a C++ XS constructor.  This is always a char*.  See THIS and the
  2039.              section on _U_s_i_n_g _X_S _W_i_t_h _C++ in the _p_e_r_l_x_s manpage.
  2040.  
  2041.  
  2042.  
  2043.                                                                        PPPPaaaaggggeeee 33331111
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2051.  
  2052.  
  2053.  
  2054.      Copy    The XSUB-writer's interface to the C memcpy function.  The s is
  2055.              the source, d is the destination, n is the number of items, and t
  2056.              is the type.  May fail on overlapping copies.  See also Move.
  2057.  
  2058.                      void    Copy( s, d, n, t )
  2059.  
  2060.  
  2061.      croak   This is the XSUB-writer's interface to Perl's die function.  Use
  2062.              this function the same way you use the C printf function.  See
  2063.              warn.
  2064.  
  2065.      CvSTASH Returns the stash of the CV.
  2066.  
  2067.                      HV*     CvSTASH( SV* sv )
  2068.  
  2069.  
  2070.      PL_DBsingle
  2071.              When Perl is run in debugging mode, with the ----dddd switch, this SV
  2072.              is a boolean which indicates whether subs are being single-
  2073.              stepped.  Single-stepping is automatically turned on after every
  2074.              step.  This is the C variable which corresponds to Perl's
  2075.              $DB::single variable.  See PL_DBsub.
  2076.  
  2077.      PL_DBsub
  2078.              When Perl is run in debugging mode, with the ----dddd switch, this GV
  2079.              contains the SV which holds the name of the sub being debugged.
  2080.              This is the C variable which corresponds to Perl's $DB::sub
  2081.              variable.  See PL_DBsingle.  The sub name can be found by
  2082.  
  2083.                      SvPV( GvSV( PL_DBsub ), PL_na )
  2084.  
  2085.  
  2086.      PL_DBtrace
  2087.              Trace variable used when Perl is run in debugging mode, with the
  2088.              ----dddd switch.  This is the C variable which corresponds to Perl's
  2089.              $DB::trace variable.  See PL_DBsingle.
  2090.  
  2091.      dMARK   Declare a stack marker variable, mark, for the XSUB.  See MARK
  2092.              and dORIGMARK.
  2093.  
  2094.      dORIGMARK
  2095.              Saves the original stack mark for the XSUB.  See ORIGMARK.
  2096.  
  2097.      PL_dowarn
  2098.              The C variable which corresponds to Perl's $^W warning variable.
  2099.  
  2100.      dSP     Declares a local copy of perl's stack pointer for the XSUB,
  2101.              available via the SP macro.  See SP.
  2102.  
  2103.      dXSARGS Sets up stack and mark pointers for an XSUB, calling dSP and
  2104.              dMARK.  This is usually handled automatically by xsubpp.
  2105.              Declares the items variable to indicate the number of items on
  2106.  
  2107.  
  2108.  
  2109.                                                                        PPPPaaaaggggeeee 33332222
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2117.  
  2118.  
  2119.  
  2120.              the stack.
  2121.  
  2122.      dXSI32  Sets up the ix variable for an XSUB which has aliases.  This is
  2123.              usually handled automatically by xsubpp.
  2124.  
  2125.      do_binmode
  2126.              Switches filehandle to binmode.  iotype is what IoTYPE(io) would
  2127.              contain.
  2128.  
  2129.                      do_binmode(fp, iotype, TRUE);
  2130.  
  2131.  
  2132.      ENTER   Opening bracket on a callback.  See LEAVE and the _p_e_r_l_c_a_l_l
  2133.              manpage.
  2134.  
  2135.                      ENTER;
  2136.  
  2137.  
  2138.      EXTEND  Used to extend the argument stack for an XSUB's return values.
  2139.  
  2140.                      EXTEND( sp, int x )
  2141.  
  2142.  
  2143.      fbm_compile
  2144.              Analyses the string in order to make fast searches on it using
  2145.              _f_b_m__i_n_s_t_r() -- the Boyer-Moore algorithm.
  2146.  
  2147.                      void    fbm_compile(SV* sv, U32 flags)
  2148.  
  2149.  
  2150.      fbm_instr
  2151.              Returns the location of the SV in the string delimited by str and
  2152.              strend.  It returns Nullch if the string can't be found.  The sv
  2153.              does not have to be fbm_compiled, but the search will not be as
  2154.              fast then.
  2155.  
  2156.                      char*   fbm_instr(char *str, char *strend, SV *sv, U32 flags)
  2157.  
  2158.  
  2159.      FREETMPS
  2160.              Closing bracket for temporaries on a callback.  See SAVETMPS and
  2161.              the _p_e_r_l_c_a_l_l manpage.
  2162.  
  2163.                      FREETMPS;
  2164.  
  2165.  
  2166.      G_ARRAY Used to indicate array context.  See GIMME_V, GIMME and the
  2167.              _p_e_r_l_c_a_l_l manpage.
  2168.  
  2169.      G_DISCARD
  2170.              Indicates that arguments returned from a callback should be
  2171.              discarded.  See the _p_e_r_l_c_a_l_l manpage.
  2172.  
  2173.  
  2174.  
  2175.                                                                        PPPPaaaaggggeeee 33333333
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2183.  
  2184.  
  2185.  
  2186.      G_EVAL  Used to force a Perl eval wrapper around a callback.  See the
  2187.              _p_e_r_l_c_a_l_l manpage.
  2188.  
  2189.      GIMME   A backward-compatible version of GIMME_V which can only return
  2190.              G_SCALAR or G_ARRAY; in a void context, it returns G_SCALAR.
  2191.  
  2192.      GIMME_V The XSUB-writer's equivalent to Perl's wantarray.  Returns
  2193.              G_VOID, G_SCALAR or G_ARRAY for void, scalar or array context,
  2194.              respectively.
  2195.  
  2196.      G_NOARGS
  2197.              Indicates that no arguments are being sent to a callback.  See
  2198.              the _p_e_r_l_c_a_l_l manpage.
  2199.  
  2200.      G_SCALAR
  2201.              Used to indicate scalar context.  See GIMME_V, GIMME, and the
  2202.              _p_e_r_l_c_a_l_l manpage.
  2203.  
  2204.      gv_fetchmeth
  2205.              Returns the glob with the given name and a defined subroutine or
  2206.              NULL.  The glob lives in the given stash, or in the stashes
  2207.              accessible via @ISA and @UNIVERSAL.
  2208.  
  2209.              The argument level should be either 0 or -1.  If level==0, as a
  2210.              side-effect creates a glob with the given name in the given stash
  2211.              which in the case of success contains an alias for the
  2212.              subroutine, and sets up caching info for this glob.  Similarly
  2213.              for all the searched stashes.
  2214.  
  2215.              This function grants "SUPER" token as a postfix of the stash
  2216.              name.
  2217.  
  2218.              The GV returned from gv_fetchmeth may be a method cache entry,
  2219.              which is not visible to Perl code.  So when calling perl_call_sv,
  2220.              you should not use the GV directly; instead, you should use the
  2221.              method's CV, which can be obtained from the GV with the GvCV
  2222.              macro.
  2223.  
  2224.                      GV*     gv_fetchmeth (HV* stash, char* name, STRLEN len, I32 level)
  2225.  
  2226.  
  2227.      gv_fetchmethod
  2228.  
  2229.      gv_fetchmethod_autoload
  2230.              Returns the glob which contains the subroutine to call to invoke
  2231.              the method on the stash.  In fact in the presense of autoloading
  2232.              this may be the glob for "AUTOLOAD".  In this case the
  2233.              corresponding variable $AUTOLOAD is already setup.
  2234.  
  2235.              The third parameter of gv_fetchmethod_autoload determines whether
  2236.              AUTOLOAD lookup is performed if the given method is not present:
  2237.              non-zero means yes, look for AUTOLOAD; zero means no, don't look
  2238.  
  2239.  
  2240.  
  2241.                                                                        PPPPaaaaggggeeee 33334444
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2249.  
  2250.  
  2251.  
  2252.              for AUTOLOAD.  Calling gv_fetchmethod is equivalent to calling
  2253.              gv_fetchmethod_autoload with a non-zero autoload parameter.
  2254.  
  2255.              These functions grant "SUPER" token as a prefix of the method
  2256.              name.
  2257.  
  2258.              Note that if you want to keep the returned glob for a long time,
  2259.              you need to check for it being "AUTOLOAD", since at the later
  2260.              time the call may load a different subroutine due to $AUTOLOAD
  2261.              changing its value.  Use the glob created via a side effect to do
  2262.              this.
  2263.  
  2264.              These functions have the same side-effects and as gv_fetchmeth
  2265.              with level==0.  name should be writable if contains ':' or '\''.
  2266.              The warning against passing the GV returned by gv_fetchmeth to
  2267.              perl_call_sv apply equally to these functions.
  2268.  
  2269.                      GV*     gv_fetchmethod (HV* stash, char* name)
  2270.                      GV*     gv_fetchmethod_autoload (HV* stash, char* name, I32 autoload)
  2271.  
  2272.  
  2273.      G_VOID  Used to indicate void context.  See GIMME_V and the _p_e_r_l_c_a_l_l
  2274.              manpage.
  2275.  
  2276.      gv_stashpv
  2277.              Returns a pointer to the stash for a specified package.  If
  2278.              create is set then the package will be created if it does not
  2279.              already exist.  If create is not set and the package does not
  2280.              exist then NULL is returned.
  2281.  
  2282.                      HV*     gv_stashpv (char* name, I32 create)
  2283.  
  2284.  
  2285.      gv_stashsv
  2286.              Returns a pointer to the stash for a specified package.  See
  2287.              gv_stashpv.
  2288.  
  2289.                      HV*     gv_stashsv (SV* sv, I32 create)
  2290.  
  2291.  
  2292.      GvSV    Return the SV from the GV.
  2293.  
  2294.      HEf_SVKEY
  2295.              This flag, used in the length slot of hash entries and magic
  2296.              structures, specifies the structure contains a SV* pointer where
  2297.              a char* pointer is to be expected. (For information only--not to
  2298.              be used).
  2299.  
  2300.      HeHASH  Returns the computed hash stored in the hash entry.
  2301.  
  2302.                      U32     HeHASH(HE* he)
  2303.  
  2304.  
  2305.  
  2306.  
  2307.                                                                        PPPPaaaaggggeeee 33335555
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2315.  
  2316.  
  2317.  
  2318.      HeKEY   Returns the actual pointer stored in the key slot of the hash
  2319.              entry.  The pointer may be either char* or SV*, depending on the
  2320.              value of HeKLEN().  Can be assigned to.  The HePV() or HeSVKEY()
  2321.              macros are usually preferable for finding the value of a key.
  2322.  
  2323.                      char*   HeKEY(HE* he)
  2324.  
  2325.  
  2326.      HeKLEN  If this is negative, and amounts to HEf_SVKEY, it indicates the
  2327.              entry holds an SV* key.  Otherwise, holds the actual length of
  2328.              the key.  Can be assigned to. The HePV() macro is usually
  2329.              preferable for finding key lengths.
  2330.  
  2331.                      int     HeKLEN(HE* he)
  2332.  
  2333.  
  2334.      HePV    Returns the key slot of the hash entry as a char* value, doing
  2335.              any necessary dereferencing of possibly SV* keys.  The length of
  2336.              the string is placed in len (this is a macro, so do _n_o_t use
  2337.              &len).  If you do not care about what the length of the key is,
  2338.              you may use the global variable PL_na.  Remember though, that
  2339.              hash keys in perl are free to contain embedded nulls, so using
  2340.              strlen() or similar is not a good way to find the length of hash
  2341.              keys.  This is very similar to the SvPV() macro described
  2342.              elsewhere in this document.
  2343.  
  2344.                      char*   HePV(HE* he, STRLEN len)
  2345.  
  2346.  
  2347.      HeSVKEY Returns the key as an SV*, or Nullsv if the hash entry does not
  2348.              contain an SV* key.
  2349.  
  2350.                      HeSVKEY(HE* he)
  2351.  
  2352.  
  2353.      HeSVKEY_force
  2354.              Returns the key as an SV*.  Will create and return a temporary
  2355.              mortal SV* if the hash entry contains only a char* key.
  2356.  
  2357.                      HeSVKEY_force(HE* he)
  2358.  
  2359.  
  2360.      HeSVKEY_set
  2361.              Sets the key to a given SV*, taking care to set the appropriate
  2362.              flags to indicate the presence of an SV* key, and returns the
  2363.              same SV*.
  2364.  
  2365.                      HeSVKEY_set(HE* he, SV* sv)
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.                                                                        PPPPaaaaggggeeee 33336666
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2381.  
  2382.  
  2383.  
  2384.      HeVAL   Returns the value slot (type SV*) stored in the hash entry.
  2385.  
  2386.                      HeVAL(HE* he)
  2387.  
  2388.  
  2389.      hv_clear
  2390.              Clears a hash, making it empty.
  2391.  
  2392.                      void    hv_clear (HV* tb)
  2393.  
  2394.  
  2395.      hv_delete
  2396.              Deletes a key/value pair in the hash.  The value SV is removed
  2397.              from the hash and returned to the caller.  The klen is the length
  2398.              of the key.  The flags value will normally be zero; if set to
  2399.              G_DISCARD then NULL will be returned.
  2400.  
  2401.                      SV*     hv_delete (HV* tb, char* key, U32 klen, I32 flags)
  2402.  
  2403.  
  2404.      hv_delete_ent
  2405.              Deletes a key/value pair in the hash.  The value SV is removed
  2406.              from the hash and returned to the caller.  The flags value will
  2407.              normally be zero; if set to G_DISCARD then NULL will be returned.
  2408.              hash can be a valid precomputed hash value, or 0 to ask for it to
  2409.              be computed.
  2410.  
  2411.                      SV*     hv_delete_ent (HV* tb, SV* key, I32 flags, U32 hash)
  2412.  
  2413.  
  2414.      hv_exists
  2415.              Returns a boolean indicating whether the specified hash key
  2416.              exists.  The klen is the length of the key.
  2417.  
  2418.                      bool    hv_exists (HV* tb, char* key, U32 klen)
  2419.  
  2420.  
  2421.      hv_exists_ent
  2422.              Returns a boolean indicating whether the specified hash key
  2423.              exists. hash can be a valid precomputed hash value, or 0 to ask
  2424.              for it to be computed.
  2425.  
  2426.                      bool    hv_exists_ent (HV* tb, SV* key, U32 hash)
  2427.  
  2428.  
  2429.      hv_fetch
  2430.              Returns the SV which corresponds to the specified key in the
  2431.              hash.  The klen is the length of the key.  If lval is set then
  2432.              the fetch will be part of a store.  Check that the return value
  2433.              is non-null before dereferencing it to a SV*.
  2434.  
  2435.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  2436.  
  2437.  
  2438.  
  2439.                                                                        PPPPaaaaggggeeee 33337777
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2447.  
  2448.  
  2449.  
  2450.              _A_r_r_a_y_s for more information on how to use this function on tied
  2451.              hashes.
  2452.  
  2453.                      SV**    hv_fetch (HV* tb, char* key, U32 klen, I32 lval)
  2454.  
  2455.  
  2456.      hv_fetch_ent
  2457.              Returns the hash entry which corresponds to the specified key in
  2458.              the hash.  hash must be a valid precomputed hash number for the
  2459.              given key, or 0 if you want the function to compute it.  IF lval
  2460.              is set then the fetch will be part of a store.  Make sure the
  2461.              return value is non-null before accessing it.  The return value
  2462.              when tb is a tied hash is a pointer to a static location, so be
  2463.              sure to make a copy of the structure if you need to store it
  2464.              somewhere.
  2465.  
  2466.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  2467.              _A_r_r_a_y_s for more information on how to use this function on tied
  2468.              hashes.
  2469.  
  2470.                      HE*     hv_fetch_ent  (HV* tb, SV* key, I32 lval, U32 hash)
  2471.  
  2472.  
  2473.      hv_iterinit
  2474.              Prepares a starting point to traverse a hash table.
  2475.  
  2476.                      I32     hv_iterinit (HV* tb)
  2477.  
  2478.              Returns the number of keys in the hash (i.e. the same as
  2479.              HvKEYS(tb)).  The return value is currently only meaningful for
  2480.              hashes without tie magic.
  2481.  
  2482.              NOTE: Before version 5.004_65, hv_iterinit used to return the
  2483.              number of hash buckets that happen to be in use.  If you still
  2484.              need that esoteric value, you can get it through the macro
  2485.              HvFILL(tb).
  2486.  
  2487.      hv_iterkey
  2488.              Returns the key from the current position of the hash iterator.
  2489.              See hv_iterinit.
  2490.  
  2491.                      char*   hv_iterkey (HE* entry, I32* retlen)
  2492.  
  2493.  
  2494.      hv_iterkeysv
  2495.              Returns the key as an SV* from the current position of the hash
  2496.              iterator.  The return value will always be a mortal copy of the
  2497.              key.  Also see hv_iterinit.
  2498.  
  2499.                      SV*     hv_iterkeysv  (HE* entry)
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.                                                                        PPPPaaaaggggeeee 33338888
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2513.  
  2514.  
  2515.  
  2516.      hv_iternext
  2517.              Returns entries from a hash iterator.  See hv_iterinit.
  2518.  
  2519.                      HE*     hv_iternext (HV* tb)
  2520.  
  2521.  
  2522.      hv_iternextsv
  2523.              Performs an hv_iternext, hv_iterkey, and hv_iterval in one
  2524.              operation.
  2525.  
  2526.                      SV*     hv_iternextsv (HV* hv, char** key, I32* retlen)
  2527.  
  2528.  
  2529.      hv_iterval
  2530.              Returns the value from the current position of the hash iterator.
  2531.              See hv_iterkey.
  2532.  
  2533.                      SV*     hv_iterval (HV* tb, HE* entry)
  2534.  
  2535.  
  2536.      hv_magic
  2537.              Adds magic to a hash.  See sv_magic.
  2538.  
  2539.                      void    hv_magic (HV* hv, GV* gv, int how)
  2540.  
  2541.  
  2542.      HvNAME  Returns the package name of a stash.  See SvSTASH, CvSTASH.
  2543.  
  2544.                      char*   HvNAME (HV* stash)
  2545.  
  2546.  
  2547.      hv_store
  2548.              Stores an SV in a hash.  The hash key is specified as key and
  2549.              klen is the length of the key.  The hash parameter is the
  2550.              precomputed hash value; if it is zero then Perl will compute it.
  2551.              The return value will be NULL if the operation failed or if the
  2552.              value did not need to be actually stored within the hash (as in
  2553.              the case of tied hashes).  Otherwise it can be dereferenced to
  2554.              get the original SV*.  Note that the caller is responsible for
  2555.              suitably incrementing the reference count of val before the call,
  2556.              and decrementing it if the function returned NULL.
  2557.  
  2558.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  2559.              _A_r_r_a_y_s for more information on how to use this function on tied
  2560.              hashes.
  2561.  
  2562.                      SV**    hv_store (HV* tb, char* key, U32 klen, SV* val, U32 hash)
  2563.  
  2564.  
  2565.      hv_store_ent
  2566.              Stores val in a hash.  The hash key is specified as key.  The
  2567.              hash parameter is the precomputed hash value; if it is zero then
  2568.  
  2569.  
  2570.  
  2571.                                                                        PPPPaaaaggggeeee 33339999
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2579.  
  2580.  
  2581.  
  2582.              Perl will compute it.  The return value is the new hash entry so
  2583.              created.  It will be NULL if the operation failed or if the value
  2584.              did not need to be actually stored within the hash (as in the
  2585.              case of tied hashes).  Otherwise the contents of the return value
  2586.              can be accessed using the He??? macros described here.  Note that
  2587.              the caller is responsible for suitably incrementing the reference
  2588.              count of val before the call, and decrementing it if the function
  2589.              returned NULL.
  2590.  
  2591.              See the section on _U_n_d_e_r_s_t_a_n_d_i_n_g _t_h_e _M_a_g_i_c _o_f _T_i_e_d _H_a_s_h_e_s _a_n_d
  2592.              _A_r_r_a_y_s for more information on how to use this function on tied
  2593.              hashes.
  2594.  
  2595.                      HE*     hv_store_ent  (HV* tb, SV* key, SV* val, U32 hash)
  2596.  
  2597.  
  2598.      hv_undef
  2599.              Undefines the hash.
  2600.  
  2601.                      void    hv_undef (HV* tb)
  2602.  
  2603.  
  2604.      isALNUM Returns a boolean indicating whether the C char is an ascii
  2605.              alphanumeric character or digit.
  2606.  
  2607.                      int     isALNUM (char c)
  2608.  
  2609.  
  2610.      isALPHA Returns a boolean indicating whether the C char is an ascii
  2611.              alphabetic character.
  2612.  
  2613.                      int     isALPHA (char c)
  2614.  
  2615.  
  2616.      isDIGIT Returns a boolean indicating whether the C char is an ascii
  2617.              digit.
  2618.  
  2619.                      int     isDIGIT (char c)
  2620.  
  2621.  
  2622.      isLOWER Returns a boolean indicating whether the C char is a lowercase
  2623.              character.
  2624.  
  2625.                      int     isLOWER (char c)
  2626.  
  2627.  
  2628.      isSPACE Returns a boolean indicating whether the C char is whitespace.
  2629.  
  2630.                      int     isSPACE (char c)
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.                                                                        PPPPaaaaggggeeee 44440000
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2645.  
  2646.  
  2647.  
  2648.      isUPPER Returns a boolean indicating whether the C char is an uppercase
  2649.              character.
  2650.  
  2651.                      int     isUPPER (char c)
  2652.  
  2653.  
  2654.      items   Variable which is setup by xsubpp to indicate the number of items
  2655.              on the stack.  See the section on _V_a_r_i_a_b_l_e-_l_e_n_g_t_h _P_a_r_a_m_e_t_e_r _L_i_s_t_s
  2656.              in the _p_e_r_l_x_s manpage.
  2657.  
  2658.      ix      Variable which is setup by xsubpp to indicate which of an XSUB's
  2659.              aliases was used to invoke it.  See the section on _T_h_e _A_L_I_A_S:
  2660.              _K_e_y_w_o_r_d in the _p_e_r_l_x_s manpage.
  2661.  
  2662.      LEAVE   Closing bracket on a callback.  See ENTER and the _p_e_r_l_c_a_l_l
  2663.              manpage.
  2664.  
  2665.                      LEAVE;
  2666.  
  2667.  
  2668.      looks_like_number
  2669.              Test if an the content of an SV looks like a number (or is a
  2670.              number).
  2671.  
  2672.                      int     looks_like_number(SV*)
  2673.  
  2674.  
  2675.      MARK    Stack marker variable for the XSUB.  See dMARK.
  2676.  
  2677.      mg_clear
  2678.              Clear something magical that the SV represents.  See sv_magic.
  2679.  
  2680.                      int     mg_clear (SV* sv)
  2681.  
  2682.  
  2683.      mg_copy Copies the magic from one SV to another.  See sv_magic.
  2684.  
  2685.                      int     mg_copy (SV *, SV *, char *, STRLEN)
  2686.  
  2687.  
  2688.      mg_find Finds the magic pointer for type matching the SV.  See sv_magic.
  2689.  
  2690.                      MAGIC*  mg_find (SV* sv, int type)
  2691.  
  2692.  
  2693.      mg_free Free any magic storage used by the SV.  See sv_magic.
  2694.  
  2695.                      int     mg_free (SV* sv)
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.                                                                        PPPPaaaaggggeeee 44441111
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2711.  
  2712.  
  2713.  
  2714.      mg_get  Do magic after a value is retrieved from the SV.  See sv_magic.
  2715.  
  2716.                      int     mg_get (SV* sv)
  2717.  
  2718.  
  2719.      mg_len  Report on the SV's length.  See sv_magic.
  2720.  
  2721.                      U32     mg_len (SV* sv)
  2722.  
  2723.  
  2724.      mg_magical
  2725.              Turns on the magical status of an SV.  See sv_magic.
  2726.  
  2727.                      void    mg_magical (SV* sv)
  2728.  
  2729.  
  2730.      mg_set  Do magic after a value is assigned to the SV.  See sv_magic.
  2731.  
  2732.                      int     mg_set (SV* sv)
  2733.  
  2734.  
  2735.      Move    The XSUB-writer's interface to the C memmove function.  The s is
  2736.              the source, d is the destination, n is the number of items, and t
  2737.              is the type.  Can do overlapping moves.  See also Copy.
  2738.  
  2739.                      void    Move( s, d, n, t )
  2740.  
  2741.  
  2742.      PL_na   A variable which may be used with SvPV to tell Perl to calculate
  2743.              the string length.
  2744.  
  2745.      New     The XSUB-writer's interface to the C malloc function.
  2746.  
  2747.                      void*   New( x, void *ptr, int size, type )
  2748.  
  2749.  
  2750.      newAV   Creates a new AV.  The reference count is set to 1.
  2751.  
  2752.                      AV*     newAV (void)
  2753.  
  2754.  
  2755.      Newc    The XSUB-writer's interface to the C malloc function, with cast.
  2756.  
  2757.                      void*   Newc( x, void *ptr, int size, type, cast )
  2758.  
  2759.  
  2760.      newCONSTSUB
  2761.              Creates a constant sub equivalent to Perl sub FOO () { 123 }
  2762.              which is eligible for inlining at compile-time.
  2763.  
  2764.                      void    newCONSTSUB(HV* stash, char* name, SV* sv)
  2765.  
  2766.  
  2767.  
  2768.  
  2769.                                                                        PPPPaaaaggggeeee 44442222
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2777.  
  2778.  
  2779.  
  2780.      newHV   Creates a new HV.  The reference count is set to 1.
  2781.  
  2782.                      HV*     newHV (void)
  2783.  
  2784.  
  2785.      newRV_inc
  2786.              Creates an RV wrapper for an SV.  The reference count for the
  2787.              original SV is incremented.
  2788.  
  2789.                      SV*     newRV_inc (SV* ref)
  2790.  
  2791.              For historical reasons, "newRV" is a synonym for "newRV_inc".
  2792.  
  2793.      newRV_noinc
  2794.              Creates an RV wrapper for an SV.  The reference count for the
  2795.              original SV is nnnnooootttt incremented.
  2796.  
  2797.                      SV*     newRV_noinc (SV* ref)
  2798.  
  2799.  
  2800.      NEWSV   Creates a new SV.  A non-zero len parameter indicates the number
  2801.              of bytes of preallocated string space the SV should have.  An
  2802.              extra byte for a tailing NUL is also reserved.  (SvPOK is not set
  2803.              for the SV even if string space is allocated.)  The reference
  2804.              count for the new SV is set to 1.  id is an integer id between 0
  2805.              and 1299 (used to identify leaks).
  2806.  
  2807.                      SV*     NEWSV (int id, STRLEN len)
  2808.  
  2809.  
  2810.      newSViv Creates a new SV and copies an integer into it.  The reference
  2811.              count for the SV is set to 1.
  2812.  
  2813.                      SV*     newSViv (IV i)
  2814.  
  2815.  
  2816.      newSVnv Creates a new SV and copies a double into it.  The reference
  2817.              count for the SV is set to 1.
  2818.  
  2819.                      SV*     newSVnv (NV i)
  2820.  
  2821.  
  2822.      newSVpv Creates a new SV and copies a string into it.  The reference
  2823.              count for the SV is set to 1.  If len is zero then Perl will
  2824.              compute the length.
  2825.  
  2826.                      SV*     newSVpv (char* s, STRLEN len)
  2827.  
  2828.  
  2829.      newSVpvf
  2830.              Creates a new SV an initialize it with the string formatted like
  2831.              sprintf.
  2832.  
  2833.  
  2834.  
  2835.                                                                        PPPPaaaaggggeeee 44443333
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2843.  
  2844.  
  2845.  
  2846.                      SV*     newSVpvf(const char* pat, ...);
  2847.  
  2848.  
  2849.      newSVpvn
  2850.              Creates a new SV and copies a string into it.  The reference
  2851.              count for the SV is set to 1.  If len is zero then Perl will
  2852.              create a zero length string.
  2853.  
  2854.                      SV*     newSVpvn (char* s, STRLEN len)
  2855.  
  2856.  
  2857.      newSVrv Creates a new SV for the RV, rv, to point to.  If rv is not an RV
  2858.              then it will be upgraded to one.  If classname is non-null then
  2859.              the new SV will be blessed in the specified package.  The new SV
  2860.              is returned and its reference count is 1.
  2861.  
  2862.                      SV*     newSVrv (SV* rv, char* classname)
  2863.  
  2864.  
  2865.      newSVsv Creates a new SV which is an exact duplicate of the original SV.
  2866.  
  2867.                      SV*     newSVsv (SV* old)
  2868.  
  2869.  
  2870.      newXS   Used by xsubpp to hook up XSUBs as Perl subs.
  2871.  
  2872.      newXSproto
  2873.              Used by xsubpp to hook up XSUBs as Perl subs.  Adds Perl
  2874.              prototypes to the subs.
  2875.  
  2876.      Newz    The XSUB-writer's interface to the C malloc function.  The
  2877.              allocated memory is zeroed with memzero.
  2878.  
  2879.                      void*   Newz( x, void *ptr, int size, type )
  2880.  
  2881.  
  2882.      Nullav  Null AV pointer.
  2883.  
  2884.      Nullch  Null character pointer.
  2885.  
  2886.      Nullcv  Null CV pointer.
  2887.  
  2888.      Nullhv  Null HV pointer.
  2889.  
  2890.      Nullsv  Null SV pointer.
  2891.  
  2892.      ORIGMARK
  2893.              The original stack mark for the XSUB.  See dORIGMARK.
  2894.  
  2895.      perl_alloc
  2896.              Allocates a new Perl interpreter.  See the _p_e_r_l_e_m_b_e_d manpage.
  2897.  
  2898.  
  2899.  
  2900.  
  2901.                                                                        PPPPaaaaggggeeee 44444444
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2909.  
  2910.  
  2911.  
  2912.      perl_call_argv
  2913.              Performs a callback to the specified Perl sub.  See the _p_e_r_l_c_a_l_l
  2914.              manpage.
  2915.  
  2916.                      I32     perl_call_argv (char* subname, I32 flags, char** argv)
  2917.  
  2918.  
  2919.      perl_call_method
  2920.              Performs a callback to the specified Perl method.  The blessed
  2921.              object must be on the stack.  See the _p_e_r_l_c_a_l_l manpage.
  2922.  
  2923.                      I32     perl_call_method (char* methname, I32 flags)
  2924.  
  2925.  
  2926.      perl_call_pv
  2927.              Performs a callback to the specified Perl sub.  See the _p_e_r_l_c_a_l_l
  2928.              manpage.
  2929.  
  2930.                      I32     perl_call_pv (char* subname, I32 flags)
  2931.  
  2932.  
  2933.      perl_call_sv
  2934.              Performs a callback to the Perl sub whose name is in the SV.  See
  2935.              the _p_e_r_l_c_a_l_l manpage.
  2936.  
  2937.                      I32     perl_call_sv (SV* sv, I32 flags)
  2938.  
  2939.  
  2940.      perl_construct
  2941.              Initializes a new Perl interpreter.  See the _p_e_r_l_e_m_b_e_d manpage.
  2942.  
  2943.      perl_destruct
  2944.              Shuts down a Perl interpreter.  See the _p_e_r_l_e_m_b_e_d manpage.
  2945.  
  2946.      perl_eval_sv
  2947.              Tells Perl to eval the string in the SV.
  2948.  
  2949.                      I32     perl_eval_sv (SV* sv, I32 flags)
  2950.  
  2951.  
  2952.      perl_eval_pv
  2953.              Tells Perl to eval the given string and return an SV* result.
  2954.  
  2955.                      SV*     perl_eval_pv (char* p, I32 croak_on_error)
  2956.  
  2957.  
  2958.      perl_free
  2959.              Releases a Perl interpreter.  See the _p_e_r_l_e_m_b_e_d manpage.
  2960.  
  2961.      perl_get_av
  2962.              Returns the AV of the specified Perl array.  If create is set and
  2963.              the Perl variable does not exist then it will be created.  If
  2964.  
  2965.  
  2966.  
  2967.                                                                        PPPPaaaaggggeeee 44445555
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  2975.  
  2976.  
  2977.  
  2978.              create is not set and the variable does not exist then NULL is
  2979.              returned.
  2980.  
  2981.                      AV*     perl_get_av (char* name, I32 create)
  2982.  
  2983.  
  2984.      perl_get_cv
  2985.              Returns the CV of the specified Perl sub.  If create is set and
  2986.              the Perl variable does not exist then it will be created.  If
  2987.              create is not set and the variable does not exist then NULL is
  2988.              returned.
  2989.  
  2990.                      CV*     perl_get_cv (char* name, I32 create)
  2991.  
  2992.  
  2993.      perl_get_hv
  2994.              Returns the HV of the specified Perl hash.  If create is set and
  2995.              the Perl variable does not exist then it will be created.  If
  2996.              create is not set and the variable does not exist then NULL is
  2997.              returned.
  2998.  
  2999.                      HV*     perl_get_hv (char* name, I32 create)
  3000.  
  3001.  
  3002.      perl_get_sv
  3003.              Returns the SV of the specified Perl scalar.  If create is set
  3004.              and the Perl variable does not exist then it will be created.  If
  3005.              create is not set and the variable does not exist then NULL is
  3006.              returned.
  3007.  
  3008.                      SV*     perl_get_sv (char* name, I32 create)
  3009.  
  3010.  
  3011.      perl_parse
  3012.              Tells a Perl interpreter to parse a Perl script.  See the
  3013.              _p_e_r_l_e_m_b_e_d manpage.
  3014.  
  3015.      perl_require_pv
  3016.              Tells Perl to require a module.
  3017.  
  3018.                      void    perl_require_pv (char* pv)
  3019.  
  3020.  
  3021.      perl_run
  3022.              Tells a Perl interpreter to run.  See the _p_e_r_l_e_m_b_e_d manpage.
  3023.  
  3024.      POPi    Pops an integer off the stack.
  3025.  
  3026.                      int     POPi()
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.                                                                        PPPPaaaaggggeeee 44446666
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3041.  
  3042.  
  3043.  
  3044.      POPl    Pops a long off the stack.
  3045.  
  3046.                      long    POPl()
  3047.  
  3048.  
  3049.      POPp    Pops a string off the stack.
  3050.  
  3051.                      char*   POPp()
  3052.  
  3053.  
  3054.      POPn    Pops a double off the stack.
  3055.  
  3056.                      double  POPn()
  3057.  
  3058.  
  3059.      POPs    Pops an SV off the stack.
  3060.  
  3061.                      SV*     POPs()
  3062.  
  3063.  
  3064.      PUSHMARK
  3065.              Opening bracket for arguments on a callback.  See PUTBACK and the
  3066.              _p_e_r_l_c_a_l_l manpage.
  3067.  
  3068.                      PUSHMARK(p)
  3069.  
  3070.  
  3071.      PUSHi   Push an integer onto the stack.  The stack must have room for
  3072.              this element.  Handles 'set' magic.  See XPUSHi.
  3073.  
  3074.                      void    PUSHi(int d)
  3075.  
  3076.  
  3077.      PUSHn   Push a double onto the stack.  The stack must have room for this
  3078.              element.  Handles 'set' magic.  See XPUSHn.
  3079.  
  3080.                      void    PUSHn(double d)
  3081.  
  3082.  
  3083.      PUSHp   Push a string onto the stack.  The stack must have room for this
  3084.              element.  The len indicates the length of the string.  Handles
  3085.              'set' magic.  See XPUSHp.
  3086.  
  3087.                      void    PUSHp(char *c, int len )
  3088.  
  3089.  
  3090.      PUSHs   Push an SV onto the stack.  The stack must have room for this
  3091.              element.  Does not handle 'set' magic.  See XPUSHs.
  3092.  
  3093.                      void    PUSHs(sv)
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.                                                                        PPPPaaaaggggeeee 44447777
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3107.  
  3108.  
  3109.  
  3110.      PUSHu   Push an unsigned integer onto the stack.  The stack must have
  3111.              room for this element.  See XPUSHu.
  3112.  
  3113.                      void    PUSHu(unsigned int d)
  3114.  
  3115.  
  3116.      PUTBACK Closing bracket for XSUB arguments.  This is usually handled by
  3117.              xsubpp.  See PUSHMARK and the _p_e_r_l_c_a_l_l manpage for other uses.
  3118.  
  3119.                      PUTBACK;
  3120.  
  3121.  
  3122.      Renew   The XSUB-writer's interface to the C realloc function.
  3123.  
  3124.                      void*   Renew( void *ptr, int size, type )
  3125.  
  3126.  
  3127.      Renewc  The XSUB-writer's interface to the C realloc function, with cast.
  3128.  
  3129.                      void*   Renewc( void *ptr, int size, type, cast )
  3130.  
  3131.  
  3132.      RETVAL  Variable which is setup by xsubpp to hold the return value for an
  3133.              XSUB.  This is always the proper type for the XSUB.  See the
  3134.              section on _T_h_e _R_E_T_V_A_L _V_a_r_i_a_b_l_e in the _p_e_r_l_x_s manpage.
  3135.  
  3136.      safefree
  3137.              The XSUB-writer's interface to the C free function.
  3138.  
  3139.      safemalloc
  3140.              The XSUB-writer's interface to the C malloc function.
  3141.  
  3142.      saferealloc
  3143.              The XSUB-writer's interface to the C realloc function.
  3144.  
  3145.      savepv  Copy a string to a safe spot.  This does not use an SV.
  3146.  
  3147.                      char*   savepv (char* sv)
  3148.  
  3149.  
  3150.      savepvn Copy a string to a safe spot.  The len indicates number of bytes
  3151.              to copy.  This does not use an SV.
  3152.  
  3153.                      char*   savepvn (char* sv, I32 len)
  3154.  
  3155.  
  3156.      SAVETMPS
  3157.              Opening bracket for temporaries on a callback.  See FREETMPS and
  3158.              the _p_e_r_l_c_a_l_l manpage.
  3159.  
  3160.                      SAVETMPS;
  3161.  
  3162.  
  3163.  
  3164.  
  3165.                                                                        PPPPaaaaggggeeee 44448888
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3173.  
  3174.  
  3175.  
  3176.      SP      Stack pointer.  This is usually handled by xsubpp.  See dSP and
  3177.              SPAGAIN.
  3178.  
  3179.      SPAGAIN Refetch the stack pointer.  Used after a callback.  See the
  3180.              _p_e_r_l_c_a_l_l manpage.
  3181.  
  3182.                      SPAGAIN;
  3183.  
  3184.  
  3185.      ST      Used to access elements on the XSUB's stack.
  3186.  
  3187.                      SV*     ST(int x)
  3188.  
  3189.  
  3190.      strEQ   Test two strings to see if they are equal.  Returns true or
  3191.              false.
  3192.  
  3193.                      int     strEQ( char *s1, char *s2 )
  3194.  
  3195.  
  3196.      strGE   Test two strings to see if the first, s1, is greater than or
  3197.              equal to the second, s2.  Returns true or false.
  3198.  
  3199.                      int     strGE( char *s1, char *s2 )
  3200.  
  3201.  
  3202.      strGT   Test two strings to see if the first, s1, is greater than the
  3203.              second, s2.  Returns true or false.
  3204.  
  3205.                      int     strGT( char *s1, char *s2 )
  3206.  
  3207.  
  3208.      strLE   Test two strings to see if the first, s1, is less than or equal
  3209.              to the second, s2.  Returns true or false.
  3210.  
  3211.                      int     strLE( char *s1, char *s2 )
  3212.  
  3213.  
  3214.      strLT   Test two strings to see if the first, s1, is less than the
  3215.              second, s2.  Returns true or false.
  3216.  
  3217.                      int     strLT( char *s1, char *s2 )
  3218.  
  3219.  
  3220.      strNE   Test two strings to see if they are different.  Returns true or
  3221.              false.
  3222.  
  3223.                      int     strNE( char *s1, char *s2 )
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.                                                                        PPPPaaaaggggeeee 44449999
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3239.  
  3240.  
  3241.  
  3242.      strnEQ  Test two strings to see if they are equal.  The len parameter
  3243.              indicates the number of bytes to compare.  Returns true or false.
  3244.  
  3245.                      int     strnEQ( char *s1, char *s2 )
  3246.  
  3247.  
  3248.      strnNE  Test two strings to see if they are different.  The len parameter
  3249.              indicates the number of bytes to compare.  Returns true or false.
  3250.  
  3251.                      int     strnNE( char *s1, char *s2, int len )
  3252.  
  3253.  
  3254.      sv_2mortal
  3255.              Marks an SV as mortal.  The SV will be destroyed when the current
  3256.              context ends.
  3257.  
  3258.                      SV*     sv_2mortal (SV* sv)
  3259.  
  3260.  
  3261.      sv_bless
  3262.              Blesses an SV into a specified package.  The SV must be an RV.
  3263.              The package must be designated by its stash (see gv_stashpv()).
  3264.              The reference count of the SV is unaffected.
  3265.  
  3266.                      SV*     sv_bless (SV* sv, HV* stash)
  3267.  
  3268.  
  3269.      sv_catpv
  3270.              Concatenates the string onto the end of the string which is in
  3271.              the SV.  Handles 'get' magic, but not 'set' magic.  See
  3272.              sv_catpv_mg.
  3273.  
  3274.                      void    sv_catpv (SV* sv, char* ptr)
  3275.  
  3276.  
  3277.      sv_catpv_mg
  3278.              Like sv_catpv, but also handles 'set' magic.
  3279.  
  3280.                      void    sv_catpvn (SV* sv, char* ptr)
  3281.  
  3282.  
  3283.      sv_catpvn
  3284.              Concatenates the string onto the end of the string which is in
  3285.              the SV.  The len indicates number of bytes to copy.  Handles
  3286.              'get' magic, but not 'set' magic.  See sv_catpvn_mg.
  3287.  
  3288.                      void    sv_catpvn (SV* sv, char* ptr, STRLEN len)
  3289.  
  3290.  
  3291.      sv_catpvn_mg
  3292.              Like sv_catpvn, but also handles 'set' magic.
  3293.  
  3294.  
  3295.  
  3296.  
  3297.                                                                        PPPPaaaaggggeeee 55550000
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3305.  
  3306.  
  3307.  
  3308.                      void    sv_catpvn_mg (SV* sv, char* ptr, STRLEN len)
  3309.  
  3310.  
  3311.      sv_catpvf
  3312.              Processes its arguments like sprintf and appends the formatted
  3313.              output to an SV.  Handles 'get' magic, but not 'set' magic.
  3314.              SvSETMAGIC() must typically be called after calling this function
  3315.              to handle 'set' magic.
  3316.  
  3317.                      void    sv_catpvf (SV* sv, const char* pat, ...)
  3318.  
  3319.  
  3320.      sv_catpvf_mg
  3321.              Like sv_catpvf, but also handles 'set' magic.
  3322.  
  3323.                      void    sv_catpvf_mg (SV* sv, const char* pat, ...)
  3324.  
  3325.  
  3326.      sv_catsv
  3327.              Concatenates the string from SV ssv onto the end of the string in
  3328.              SV dsv.  Handles 'get' magic, but not 'set' magic.  See
  3329.              sv_catsv_mg.
  3330.  
  3331.                      void    sv_catsv (SV* dsv, SV* ssv)
  3332.  
  3333.  
  3334.      sv_catsv_mg
  3335.              Like sv_catsv, but also handles 'set' magic.
  3336.  
  3337.                      void    sv_catsv_mg (SV* dsv, SV* ssv)
  3338.  
  3339.  
  3340.      sv_chop Efficient removal of characters from the beginning of the string
  3341.              buffer.  _S_v_P_O_K(sv) must be true and the ptr must be a pointer to
  3342.              somewhere inside the string buffer.  The ptr becomes the first
  3343.              character of the adjusted string.
  3344.  
  3345.                      void    sv_chop(SV* sv, char *ptr)
  3346.  
  3347.  
  3348.      sv_cmp  Compares the strings in two SVs.  Returns -1, 0, or 1 indicating
  3349.              whether the string in sv1 is less than, equal to, or greater than
  3350.              the string in sv2.
  3351.  
  3352.                      I32     sv_cmp (SV* sv1, SV* sv2)
  3353.  
  3354.  
  3355.      SvCUR   Returns the length of the string which is in the SV.  See SvLEN.
  3356.  
  3357.                      int     SvCUR (SV* sv)
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.                                                                        PPPPaaaaggggeeee 55551111
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3371.  
  3372.  
  3373.  
  3374.      SvCUR_set
  3375.              Set the length of the string which is in the SV.  See SvCUR.
  3376.  
  3377.                      void    SvCUR_set (SV* sv, int val )
  3378.  
  3379.  
  3380.      sv_dec  Auto-decrement of the value in the SV.
  3381.  
  3382.                      void    sv_dec (SV* sv)
  3383.  
  3384.  
  3385.      sv_derived_from
  3386.              Returns a boolean indicating whether the SV is a subclass of the
  3387.              specified class.
  3388.  
  3389.                      int     sv_derived_from(SV* sv, char* class)
  3390.  
  3391.  
  3392.      sv_derived_from
  3393.              Returns a boolean indicating whether the SV is derived from the
  3394.              specified class.  This is the function that implements
  3395.              UNIVERSAL::isa.  It works for class names as well as for objects.
  3396.  
  3397.                      bool    sv_derived_from _((SV* sv, char* name));
  3398.  
  3399.  
  3400.      SvEND   Returns a pointer to the last character in the string which is in
  3401.              the SV.  See SvCUR.  Access the character as
  3402.  
  3403.                      char*   SvEND(sv)
  3404.  
  3405.  
  3406.      sv_eq   Returns a boolean indicating whether the strings in the two SVs
  3407.              are identical.
  3408.  
  3409.                      I32     sv_eq (SV* sv1, SV* sv2)
  3410.  
  3411.  
  3412.      SvGETMAGIC
  3413.              Invokes mg_get on an SV if it has 'get' magic.  This macro
  3414.              evaluates its argument more than once.
  3415.  
  3416.                      void    SvGETMAGIC( SV *sv )
  3417.  
  3418.  
  3419.      SvGROW  Expands the character buffer in the SV so that it has room for
  3420.              the indicated number of bytes (remember to reserve space for an
  3421.              extra trailing NUL character).  Calls sv_grow to perform the
  3422.              expansion if necessary.  Returns a pointer to the character
  3423.              buffer.
  3424.  
  3425.                      char*   SvGROW( SV* sv, STRLEN len )
  3426.  
  3427.  
  3428.  
  3429.                                                                        PPPPaaaaggggeeee 55552222
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3437.  
  3438.  
  3439.  
  3440.      sv_grow Expands the character buffer in the SV.  This will use sv_unref
  3441.              and will upgrade the SV to SVt_PV.  Returns a pointer to the
  3442.              character buffer.  Use SvGROW.
  3443.  
  3444.      sv_inc  Auto-increment of the value in the SV.
  3445.  
  3446.                      void    sv_inc (SV* sv)
  3447.  
  3448.  
  3449.      sv_insert
  3450.              Inserts a string at the specified offset/length within the SV.
  3451.              Similar to the Perl _s_u_b_s_t_r() function.
  3452.  
  3453.                      void    sv_insert(SV *sv, STRLEN offset, STRLEN len,
  3454.                                        char *str, STRLEN strlen)
  3455.  
  3456.  
  3457.      SvIOK   Returns a boolean indicating whether the SV contains an integer.
  3458.  
  3459.                      int     SvIOK (SV* SV)
  3460.  
  3461.  
  3462.      SvIOK_off
  3463.              Unsets the IV status of an SV.
  3464.  
  3465.                      void    SvIOK_off (SV* sv)
  3466.  
  3467.  
  3468.      SvIOK_on
  3469.              Tells an SV that it is an integer.
  3470.  
  3471.                      void    SvIOK_on (SV* sv)
  3472.  
  3473.  
  3474.      SvIOK_only
  3475.              Tells an SV that it is an integer and disables all other OK bits.
  3476.  
  3477.                      void    SvIOK_only (SV* sv)
  3478.  
  3479.  
  3480.      SvIOKp  Returns a boolean indicating whether the SV contains an integer.
  3481.              Checks the pppprrrriiiivvvvaaaatttteeee setting.  Use SvIOK.
  3482.  
  3483.                      int     SvIOKp (SV* SV)
  3484.  
  3485.  
  3486.      sv_isa  Returns a boolean indicating whether the SV is blessed into the
  3487.              specified class.  This does not check for subtypes; use
  3488.              sv_derived_from to verify an inheritance relationship.
  3489.  
  3490.                      int     sv_isa (SV* sv, char* name)
  3491.  
  3492.  
  3493.  
  3494.  
  3495.                                                                        PPPPaaaaggggeeee 55553333
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3503.  
  3504.  
  3505.  
  3506.      sv_isobject
  3507.              Returns a boolean indicating whether the SV is an RV pointing to
  3508.              a blessed object.  If the SV is not an RV, or if the object is
  3509.              not blessed, then this will return false.
  3510.  
  3511.                      int     sv_isobject (SV* sv)
  3512.  
  3513.  
  3514.      SvIV    Returns the integer which is in the SV.
  3515.  
  3516.                      int SvIV (SV* sv)
  3517.  
  3518.  
  3519.      SvIVX   Returns the integer which is stored in the SV.
  3520.  
  3521.                      int     SvIVX (SV* sv)
  3522.  
  3523.  
  3524.      SvLEN   Returns the size of the string buffer in the SV.  See SvCUR.
  3525.  
  3526.                      int     SvLEN (SV* sv)
  3527.  
  3528.  
  3529.      sv_len  Returns the length of the string in the SV.  Use SvCUR.
  3530.  
  3531.                      STRLEN  sv_len (SV* sv)
  3532.  
  3533.  
  3534.      sv_magic
  3535.              Adds magic to an SV.
  3536.  
  3537.                      void    sv_magic (SV* sv, SV* obj, int how, char* name, I32 namlen)
  3538.  
  3539.  
  3540.      sv_mortalcopy
  3541.              Creates a new SV which is a copy of the original SV.  The new SV
  3542.              is marked as mortal.
  3543.  
  3544.                      SV*     sv_mortalcopy (SV* oldsv)
  3545.  
  3546.  
  3547.      sv_newmortal
  3548.              Creates a new SV which is mortal.  The reference count of the SV
  3549.              is set to 1.
  3550.  
  3551.                      SV*     sv_newmortal (void)
  3552.  
  3553.  
  3554.      SvNIOK  Returns a boolean indicating whether the SV contains a number,
  3555.              integer or double.
  3556.  
  3557.                      int     SvNIOK (SV* SV)
  3558.  
  3559.  
  3560.  
  3561.                                                                        PPPPaaaaggggeeee 55554444
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3569.  
  3570.  
  3571.  
  3572.      SvNIOK_off
  3573.              Unsets the NV/IV status of an SV.
  3574.  
  3575.                      void    SvNIOK_off (SV* sv)
  3576.  
  3577.  
  3578.      SvNIOKp Returns a boolean indicating whether the SV contains a number,
  3579.              integer or double.  Checks the pppprrrriiiivvvvaaaatttteeee setting.  Use SvNIOK.
  3580.  
  3581.                      int     SvNIOKp (SV* SV)
  3582.  
  3583.  
  3584.      PL_sv_no
  3585.              This is the false SV.  See PL_sv_yes.  Always refer to this as
  3586.              &PL_sv_no.
  3587.  
  3588.      SvNOK   Returns a boolean indicating whether the SV contains a double.
  3589.  
  3590.                      int     SvNOK (SV* SV)
  3591.  
  3592.  
  3593.      SvNOK_off
  3594.              Unsets the NV status of an SV.
  3595.  
  3596.                      void    SvNOK_off (SV* sv)
  3597.  
  3598.  
  3599.      SvNOK_on
  3600.              Tells an SV that it is a double.
  3601.  
  3602.                      void    SvNOK_on (SV* sv)
  3603.  
  3604.  
  3605.      SvNOK_only
  3606.              Tells an SV that it is a double and disables all other OK bits.
  3607.  
  3608.                      void    SvNOK_only (SV* sv)
  3609.  
  3610.  
  3611.      SvNOKp  Returns a boolean indicating whether the SV contains a double.
  3612.              Checks the pppprrrriiiivvvvaaaatttteeee setting.  Use SvNOK.
  3613.  
  3614.                      int     SvNOKp (SV* SV)
  3615.  
  3616.  
  3617.      SvNV    Returns the double which is stored in the SV.
  3618.  
  3619.                      double  SvNV (SV* sv)
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.                                                                        PPPPaaaaggggeeee 55555555
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3635.  
  3636.  
  3637.  
  3638.      SvNVX   Returns the double which is stored in the SV.
  3639.  
  3640.                      double  SvNVX (SV* sv)
  3641.  
  3642.  
  3643.      SvOK    Returns a boolean indicating whether the value is an SV.
  3644.  
  3645.                      int     SvOK (SV* sv)
  3646.  
  3647.  
  3648.      SvOOK   Returns a boolean indicating whether the SvIVX is a valid offset
  3649.              value for the SvPVX.  This hack is used internally to speed up
  3650.              removal of characters from the beginning of a SvPV.  When SvOOK
  3651.              is true, then the start of the allocated string buffer is really
  3652.              (SvPVX - SvIVX).
  3653.  
  3654.                      int     SvOOK(SV* sv)
  3655.  
  3656.  
  3657.      SvPOK   Returns a boolean indicating whether the SV contains a character
  3658.              string.
  3659.  
  3660.                      int     SvPOK (SV* SV)
  3661.  
  3662.  
  3663.      SvPOK_off
  3664.              Unsets the PV status of an SV.
  3665.  
  3666.                      void    SvPOK_off (SV* sv)
  3667.  
  3668.  
  3669.      SvPOK_on
  3670.              Tells an SV that it is a string.
  3671.  
  3672.                      void    SvPOK_on (SV* sv)
  3673.  
  3674.  
  3675.      SvPOK_only
  3676.              Tells an SV that it is a string and disables all other OK bits.
  3677.  
  3678.                      void    SvPOK_only (SV* sv)
  3679.  
  3680.  
  3681.      SvPOKp  Returns a boolean indicating whether the SV contains a character
  3682.              string.  Checks the pppprrrriiiivvvvaaaatttteeee setting.  Use SvPOK.
  3683.  
  3684.                      int     SvPOKp (SV* SV)
  3685.  
  3686.  
  3687.      SvPV    Returns a pointer to the string in the SV, or a stringified form
  3688.              of the SV if the SV does not contain a string.  If len is PL_na
  3689.              then Perl will handle the length on its own.  Handles 'get'
  3690.  
  3691.  
  3692.  
  3693.                                                                        PPPPaaaaggggeeee 55556666
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3701.  
  3702.  
  3703.  
  3704.              magic.
  3705.  
  3706.                      char*   SvPV (SV* sv, int len )
  3707.  
  3708.  
  3709.      SvPV_force
  3710.              Like <SvPV> but will force the SV into becoming a string (SvPOK).
  3711.              You want force if you are going to update the SvPVX directly.
  3712.  
  3713.                      char*   SvPV_force(SV* sv, int len)
  3714.  
  3715.  
  3716.      SvPVX   Returns a pointer to the string in the SV.  The SV must contain a
  3717.              string.
  3718.  
  3719.                      char*   SvPVX (SV* sv)
  3720.  
  3721.  
  3722.      SvREFCNT
  3723.              Returns the value of the object's reference count.
  3724.  
  3725.                      int     SvREFCNT (SV* sv)
  3726.  
  3727.  
  3728.      SvREFCNT_dec
  3729.              Decrements the reference count of the given SV.
  3730.  
  3731.                      void    SvREFCNT_dec (SV* sv)
  3732.  
  3733.  
  3734.      SvREFCNT_inc
  3735.              Increments the reference count of the given SV.
  3736.  
  3737.                      void    SvREFCNT_inc (SV* sv)
  3738.  
  3739.  
  3740.      SvROK   Tests if the SV is an RV.
  3741.  
  3742.                      int     SvROK (SV* sv)
  3743.  
  3744.  
  3745.      SvROK_off
  3746.              Unsets the RV status of an SV.
  3747.  
  3748.                      void    SvROK_off (SV* sv)
  3749.  
  3750.  
  3751.      SvROK_on
  3752.              Tells an SV that it is an RV.
  3753.  
  3754.                      void    SvROK_on (SV* sv)
  3755.  
  3756.  
  3757.  
  3758.  
  3759.                                                                        PPPPaaaaggggeeee 55557777
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3767.  
  3768.  
  3769.  
  3770.      SvRV    Dereferences an RV to return the SV.
  3771.  
  3772.                      SV*     SvRV (SV* sv)
  3773.  
  3774.  
  3775.      SvSETMAGIC
  3776.              Invokes mg_set on an SV if it has 'set' magic.  This macro
  3777.              evaluates its argument more than once.
  3778.  
  3779.                      void    SvSETMAGIC( SV *sv )
  3780.  
  3781.  
  3782.      sv_setiv
  3783.              Copies an integer into the given SV.  Does not handle 'set'
  3784.              magic.  See sv_setiv_mg.
  3785.  
  3786.                      void    sv_setiv (SV* sv, IV num)
  3787.  
  3788.  
  3789.      sv_setiv_mg
  3790.              Like sv_setiv, but also handles 'set' magic.
  3791.  
  3792.                      void    sv_setiv_mg (SV* sv, IV num)
  3793.  
  3794.  
  3795.      sv_setnv
  3796.              Copies a double into the given SV.  Does not handle 'set' magic.
  3797.              See sv_setnv_mg.
  3798.  
  3799.                      void    sv_setnv (SV* sv, double num)
  3800.  
  3801.  
  3802.      sv_setnv_mg
  3803.              Like sv_setnv, but also handles 'set' magic.
  3804.  
  3805.                      void    sv_setnv_mg (SV* sv, double num)
  3806.  
  3807.  
  3808.      sv_setpv
  3809.              Copies a string into an SV.  The string must be null-terminated.
  3810.              Does not handle 'set' magic.  See sv_setpv_mg.
  3811.  
  3812.                      void    sv_setpv (SV* sv, char* ptr)
  3813.  
  3814.  
  3815.      sv_setpv_mg
  3816.              Like sv_setpv, but also handles 'set' magic.
  3817.  
  3818.                      void    sv_setpv_mg (SV* sv, char* ptr)
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.                                                                        PPPPaaaaggggeeee 55558888
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3833.  
  3834.  
  3835.  
  3836.      sv_setpviv
  3837.              Copies an integer into the given SV, also updating its string
  3838.              value.  Does not handle 'set' magic.  See sv_setpviv_mg.
  3839.  
  3840.                      void    sv_setpviv (SV* sv, IV num)
  3841.  
  3842.  
  3843.      sv_setpviv_mg
  3844.              Like sv_setpviv, but also handles 'set' magic.
  3845.  
  3846.                      void    sv_setpviv_mg (SV* sv, IV num)
  3847.  
  3848.  
  3849.      sv_setpvn
  3850.              Copies a string into an SV.  The len parameter indicates the
  3851.              number of bytes to be copied.  Does not handle 'set' magic.  See
  3852.              sv_setpvn_mg.
  3853.  
  3854.                      void    sv_setpvn (SV* sv, char* ptr, STRLEN len)
  3855.  
  3856.  
  3857.      sv_setpvn_mg
  3858.              Like sv_setpvn, but also handles 'set' magic.
  3859.  
  3860.                      void    sv_setpvn_mg (SV* sv, char* ptr, STRLEN len)
  3861.  
  3862.  
  3863.      sv_setpvf
  3864.              Processes its arguments like sprintf and sets an SV to the
  3865.              formatted output.  Does not handle 'set' magic.  See
  3866.              sv_setpvf_mg.
  3867.  
  3868.                      void    sv_setpvf (SV* sv, const char* pat, ...)
  3869.  
  3870.  
  3871.      sv_setpvf_mg
  3872.              Like sv_setpvf, but also handles 'set' magic.
  3873.  
  3874.                      void    sv_setpvf_mg (SV* sv, const char* pat, ...)
  3875.  
  3876.  
  3877.      sv_setref_iv
  3878.              Copies an integer into a new SV, optionally blessing the SV.  The
  3879.              rv argument will be upgraded to an RV.  That RV will be modified
  3880.              to point to the new SV.  The classname argument indicates the
  3881.              package for the blessing.  Set classname to Nullch to avoid the
  3882.              blessing.  The new SV will be returned and will have a reference
  3883.              count of 1.
  3884.  
  3885.                      SV*     sv_setref_iv (SV *rv, char *classname, IV iv)
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.                                                                        PPPPaaaaggggeeee 55559999
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3899.  
  3900.  
  3901.  
  3902.      sv_setref_nv
  3903.              Copies a double into a new SV, optionally blessing the SV.  The
  3904.              rv argument will be upgraded to an RV.  That RV will be modified
  3905.              to point to the new SV.  The classname argument indicates the
  3906.              package for the blessing.  Set classname to Nullch to avoid the
  3907.              blessing.  The new SV will be returned and will have a reference
  3908.              count of 1.
  3909.  
  3910.                      SV*     sv_setref_nv (SV *rv, char *classname, double nv)
  3911.  
  3912.  
  3913.      sv_setref_pv
  3914.              Copies a pointer into a new SV, optionally blessing the SV.  The
  3915.              rv argument will be upgraded to an RV.  That RV will be modified
  3916.              to point to the new SV.  If the pv argument is NULL then
  3917.              PL_sv_undef will be placed into the SV.  The classname argument
  3918.              indicates the package for the blessing.  Set classname to Nullch
  3919.              to avoid the blessing.  The new SV will be returned and will have
  3920.              a reference count of 1.
  3921.  
  3922.                      SV*     sv_setref_pv (SV *rv, char *classname, void* pv)
  3923.  
  3924.              Do not use with integral Perl types such as HV, AV, SV, CV,
  3925.              because those objects will become corrupted by the pointer copy
  3926.              process.
  3927.  
  3928.              Note that sv_setref_pvn copies the string while this copies the
  3929.              pointer.
  3930.  
  3931.      sv_setref_pvn
  3932.              Copies a string into a new SV, optionally blessing the SV.  The
  3933.              length of the string must be specified with n.  The rv argument
  3934.              will be upgraded to an RV.  That RV will be modified to point to
  3935.              the new SV.  The classname argument indicates the package for the
  3936.              blessing.  Set classname to Nullch to avoid the blessing.  The
  3937.              new SV will be returned and will have a reference count of 1.
  3938.  
  3939.                      SV*     sv_setref_pvn (SV *rv, char *classname, char* pv, I32 n)
  3940.  
  3941.              Note that sv_setref_pv copies the pointer while this copies the
  3942.              string.
  3943.  
  3944.      SvSetSV Calls sv_setsv if dsv is not the same as ssv.  May evaluate
  3945.              arguments more than once.
  3946.  
  3947.                      void    SvSetSV (SV* dsv, SV* ssv)
  3948.  
  3949.  
  3950.      SvSetSV_nosteal
  3951.              Calls a non-destructive version of sv_setsv if dsv is not the
  3952.              same as ssv.  May evaluate arguments more than once.
  3953.  
  3954.  
  3955.  
  3956.  
  3957.                                                                        PPPPaaaaggggeeee 66660000
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  3965.  
  3966.  
  3967.  
  3968.                      void    SvSetSV_nosteal (SV* dsv, SV* ssv)
  3969.  
  3970.  
  3971.      sv_setsv
  3972.              Copies the contents of the source SV ssv into the destination SV
  3973.              dsv.  The source SV may be destroyed if it is mortal.  Does not
  3974.              handle 'set' magic.  See the macro forms SvSetSV, SvSetSV_nosteal
  3975.              and sv_setsv_mg.
  3976.  
  3977.                      void    sv_setsv (SV* dsv, SV* ssv)
  3978.  
  3979.  
  3980.      sv_setsv_mg
  3981.              Like sv_setsv, but also handles 'set' magic.
  3982.  
  3983.                      void    sv_setsv_mg (SV* dsv, SV* ssv)
  3984.  
  3985.  
  3986.      sv_setuv
  3987.              Copies an unsigned integer into the given SV.  Does not handle
  3988.              'set' magic.  See sv_setuv_mg.
  3989.  
  3990.                      void    sv_setuv (SV* sv, UV num)
  3991.  
  3992.  
  3993.      sv_setuv_mg
  3994.              Like sv_setuv, but also handles 'set' magic.
  3995.  
  3996.                      void    sv_setuv_mg (SV* sv, UV num)
  3997.  
  3998.  
  3999.      SvSTASH Returns the stash of the SV.
  4000.  
  4001.                      HV*     SvSTASH (SV* sv)
  4002.  
  4003.  
  4004.      SvTAINT Taints an SV if tainting is enabled
  4005.  
  4006.                      void    SvTAINT (SV* sv)
  4007.  
  4008.  
  4009.      SvTAINTED
  4010.              Checks to see if an SV is tainted. Returns TRUE if it is, FALSE
  4011.              if not.
  4012.  
  4013.                      int     SvTAINTED (SV* sv)
  4014.  
  4015.  
  4016.      SvTAINTED_off
  4017.              Untaints an SV. Be _v_e_r_y careful with this routine, as it short-
  4018.              circuits some of Perl's fundamental security features. XS module
  4019.              authors should not use this function unless they fully understand
  4020.  
  4021.  
  4022.  
  4023.                                                                        PPPPaaaaggggeeee 66661111
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4031.  
  4032.  
  4033.  
  4034.              all the implications of unconditionally untainting the value.
  4035.              Untainting should be done in the standard perl fashion, via a
  4036.              carefully crafted regexp, rather than directly untainting
  4037.              variables.
  4038.  
  4039.                      void    SvTAINTED_off (SV* sv)
  4040.  
  4041.  
  4042.      SvTAINTED_on
  4043.              Marks an SV as tainted.
  4044.  
  4045.                      void    SvTAINTED_on (SV* sv)
  4046.  
  4047.  
  4048.      SVt_IV  Integer type flag for scalars.  See svtype.
  4049.  
  4050.      SVt_PV  Pointer type flag for scalars.  See svtype.
  4051.  
  4052.      SVt_PVAV
  4053.              Type flag for arrays.  See svtype.
  4054.  
  4055.      SVt_PVCV
  4056.              Type flag for code refs.  See svtype.
  4057.  
  4058.      SVt_PVHV
  4059.              Type flag for hashes.  See svtype.
  4060.  
  4061.      SVt_PVMG
  4062.              Type flag for blessed scalars.  See svtype.
  4063.  
  4064.      SVt_NV  Double type flag for scalars.  See svtype.
  4065.  
  4066.      SvTRUE  Returns a boolean indicating whether Perl would evaluate the SV
  4067.              as true or false, defined or undefined.  Does not handle 'get'
  4068.              magic.
  4069.  
  4070.                      int     SvTRUE (SV* sv)
  4071.  
  4072.  
  4073.      SvTYPE  Returns the type of the SV.  See svtype.
  4074.  
  4075.                      svtype  SvTYPE (SV* sv)
  4076.  
  4077.  
  4078.      svtype  An enum of flags for Perl types.  These are found in the file
  4079.              ssssvvvv....hhhh in the svtype enum.  Test these flags with the SvTYPE macro.
  4080.  
  4081.      PL_sv_undef
  4082.              This is the undef SV.  Always refer to this as &PL_sv_undef.
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.                                                                        PPPPaaaaggggeeee 66662222
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4097.  
  4098.  
  4099.  
  4100.      sv_unref
  4101.              Unsets the RV status of the SV, and decrements the reference
  4102.              count of whatever was being referenced by the RV.  This can
  4103.              almost be thought of as a reversal of newSVrv.  See SvROK_off.
  4104.  
  4105.                      void    sv_unref (SV* sv)
  4106.  
  4107.  
  4108.      SvUPGRADE
  4109.              Used to upgrade an SV to a more complex form.  Uses sv_upgrade to
  4110.              perform the upgrade if necessary.  See svtype.
  4111.  
  4112.                      bool    SvUPGRADE (SV* sv, svtype mt)
  4113.  
  4114.  
  4115.      sv_upgrade
  4116.              Upgrade an SV to a more complex form.  Use SvUPGRADE.  See
  4117.              svtype.
  4118.  
  4119.      sv_usepvn
  4120.              Tells an SV to use ptr to find its string value.  Normally the
  4121.              string is stored inside the SV but sv_usepvn allows the SV to use
  4122.              an outside string.  The ptr should point to memory that was
  4123.              allocated by malloc.  The string length, len, must be supplied.
  4124.              This function will realloc the memory pointed to by ptr, so that
  4125.              pointer should not be freed or used by the programmer after
  4126.              giving it to sv_usepvn.  Does not handle 'set' magic.  See
  4127.              sv_usepvn_mg.
  4128.  
  4129.                      void    sv_usepvn (SV* sv, char* ptr, STRLEN len)
  4130.  
  4131.  
  4132.      sv_usepvn_mg
  4133.              Like sv_usepvn, but also handles 'set' magic.
  4134.  
  4135.                      void    sv_usepvn_mg (SV* sv, char* ptr, STRLEN len)
  4136.  
  4137.  
  4138.      sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)
  4139.              Processes its arguments like vsprintf and appends the formatted
  4140.              output to an SV.  Uses an array of SVs if the C style variable
  4141.              argument list is missing (NULL).  Indicates if locale information
  4142.              has been used for formatting.
  4143.  
  4144.                      void    sv_catpvfn _((SV* sv, const char* pat, STRLEN patlen,
  4145.                                            va_list *args, SV **svargs, I32 svmax,
  4146.                                            bool *used_locale));
  4147.  
  4148.  
  4149.      sv_vsetpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)
  4150.              Works like vcatpvfn but copies the text into the SV instead of
  4151.              appending it.
  4152.  
  4153.  
  4154.  
  4155.                                                                        PPPPaaaaggggeeee 66663333
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4163.  
  4164.  
  4165.  
  4166.                      void    sv_setpvfn _((SV* sv, const char* pat, STRLEN patlen,
  4167.                                            va_list *args, SV **svargs, I32 svmax,
  4168.                                            bool *used_locale));
  4169.  
  4170.  
  4171.      SvUV    Returns the unsigned integer which is in the SV.
  4172.  
  4173.                      UV      SvUV(SV* sv)
  4174.  
  4175.  
  4176.      SvUVX   Returns the unsigned integer which is stored in the SV.
  4177.  
  4178.                      UV      SvUVX(SV* sv)
  4179.  
  4180.  
  4181.      PL_sv_yes
  4182.              This is the true SV.  See PL_sv_no.  Always refer to this as
  4183.              &PL_sv_yes.
  4184.  
  4185.      THIS    Variable which is setup by xsubpp to designate the object in a
  4186.              C++ XSUB.  This is always the proper type for the C++ object.
  4187.              See CLASS and the section on _U_s_i_n_g _X_S _W_i_t_h _C++ in the _p_e_r_l_x_s
  4188.              manpage.
  4189.  
  4190.      toLOWER Converts the specified character to lowercase.
  4191.  
  4192.                      int     toLOWER (char c)
  4193.  
  4194.  
  4195.      toUPPER Converts the specified character to uppercase.
  4196.  
  4197.                      int     toUPPER (char c)
  4198.  
  4199.  
  4200.      warn    This is the XSUB-writer's interface to Perl's warn function.  Use
  4201.              this function the same way you use the C printf function.  See
  4202.              croak().
  4203.  
  4204.      XPUSHi  Push an integer onto the stack, extending the stack if necessary.
  4205.              Handles 'set' magic. See PUSHi.
  4206.  
  4207.                      XPUSHi(int d)
  4208.  
  4209.  
  4210.      XPUSHn  Push a double onto the stack, extending the stack if necessary.
  4211.              Handles 'set' magic.  See PUSHn.
  4212.  
  4213.                      XPUSHn(double d)
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.                                                                        PPPPaaaaggggeeee 66664444
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4229.  
  4230.  
  4231.  
  4232.      XPUSHp  Push a string onto the stack, extending the stack if necessary.
  4233.              The len indicates the length of the string.  Handles 'set' magic.
  4234.              See PUSHp.
  4235.  
  4236.                      XPUSHp(char *c, int len)
  4237.  
  4238.  
  4239.      XPUSHs  Push an SV onto the stack, extending the stack if necessary.
  4240.              Does not handle 'set' magic.  See PUSHs.
  4241.  
  4242.                      XPUSHs(sv)
  4243.  
  4244.  
  4245.      XPUSHu  Push an unsigned integer onto the stack, extending the stack if
  4246.              necessary.  See PUSHu.
  4247.  
  4248.      XS      Macro to declare an XSUB and its C parameter list.  This is
  4249.              handled by xsubpp.
  4250.  
  4251.      XSRETURN
  4252.              Return from XSUB, indicating number of items on the stack.  This
  4253.              is usually handled by xsubpp.
  4254.  
  4255.                      XSRETURN(int x)
  4256.  
  4257.  
  4258.      XSRETURN_EMPTY
  4259.              Return an empty list from an XSUB immediately.
  4260.  
  4261.                      XSRETURN_EMPTY;
  4262.  
  4263.  
  4264.      XSRETURN_IV
  4265.              Return an integer from an XSUB immediately.  Uses XST_mIV.
  4266.  
  4267.                      XSRETURN_IV(IV v)
  4268.  
  4269.  
  4270.      XSRETURN_NO
  4271.              Return &PL_sv_no from an XSUB immediately.  Uses XST_mNO.
  4272.  
  4273.                      XSRETURN_NO;
  4274.  
  4275.  
  4276.      XSRETURN_NV
  4277.              Return an double from an XSUB immediately.  Uses XST_mNV.
  4278.  
  4279.                      XSRETURN_NV(NV v)
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.                                                                        PPPPaaaaggggeeee 66665555
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4295.  
  4296.  
  4297.  
  4298.      XSRETURN_PV
  4299.              Return a copy of a string from an XSUB immediately.  Uses
  4300.              XST_mPV.
  4301.  
  4302.                      XSRETURN_PV(char *v)
  4303.  
  4304.  
  4305.      XSRETURN_UNDEF
  4306.              Return &PL_sv_undef from an XSUB immediately.  Uses XST_mUNDEF.
  4307.  
  4308.                      XSRETURN_UNDEF;
  4309.  
  4310.  
  4311.      XSRETURN_YES
  4312.              Return &PL_sv_yes from an XSUB immediately.  Uses XST_mYES.
  4313.  
  4314.                      XSRETURN_YES;
  4315.  
  4316.  
  4317.      XST_mIV Place an integer into the specified position i on the stack.  The
  4318.              value is stored in a new mortal SV.
  4319.  
  4320.                      XST_mIV( int i, IV v )
  4321.  
  4322.  
  4323.      XST_mNV Place a double into the specified position i on the stack.  The
  4324.              value is stored in a new mortal SV.
  4325.  
  4326.                      XST_mNV( int i, NV v )
  4327.  
  4328.  
  4329.      XST_mNO Place &PL_sv_no into the specified position i on the stack.
  4330.  
  4331.                      XST_mNO( int i )
  4332.  
  4333.  
  4334.      XST_mPV Place a copy of a string into the specified position i on the
  4335.              stack.  The value is stored in a new mortal SV.
  4336.  
  4337.                      XST_mPV( int i, char *v )
  4338.  
  4339.  
  4340.      XST_mUNDEF
  4341.              Place &PL_sv_undef into the specified position i on the stack.
  4342.  
  4343.                      XST_mUNDEF( int i )
  4344.  
  4345.  
  4346.      XST_mYES
  4347.              Place &PL_sv_yes into the specified position i on the stack.
  4348.  
  4349.                      XST_mYES( int i )
  4350.  
  4351.  
  4352.  
  4353.                                                                        PPPPaaaaggggeeee 66666666
  4354.  
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4361.  
  4362.  
  4363.  
  4364.      XS_VERSION
  4365.              The version identifier for an XS module.  This is usually handled
  4366.              automatically by ExtUtils::MakeMaker.  See XS_VERSION_BOOTCHECK.
  4367.  
  4368.      XS_VERSION_BOOTCHECK
  4369.              Macro to verify that a PM module's $VERSION variable matches the
  4370.              XS module's XS_VERSION variable.  This is usually handled
  4371.              automatically by xsubpp.  See the section on _T_h_e _V_E_R_S_I_O_N_C_H_E_C_K:
  4372.              _K_e_y_w_o_r_d in the _p_e_r_l_x_s manpage.
  4373.  
  4374.      Zero    The XSUB-writer's interface to the C memzero function.  The d is
  4375.              the destination, n is the number of items, and t is the type.
  4376.  
  4377.                      void    Zero( d, n, t )
  4378.  
  4379.  
  4380. AAAAUUUUTTTTHHHHOOOORRRRSSSS
  4381.      Until May 1997, this document was maintained by Jeff Okamoto
  4382.      <okamoto@corp.hp.com>.  It is now maintained as part of Perl itself.
  4383.  
  4384.      With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
  4385.      Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
  4386.      Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
  4387.      Stephen McCamant, and Gurusamy Sarathy.
  4388.  
  4389.      API Listing originally by Dean Roehrich <roehrich@cray.com>.
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.                                                                        PPPPaaaaggggeeee 66667777
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426. PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))                                                        PPPPEEEERRRRLLLLGGGGUUUUTTTTSSSS((((1111))))
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439.  
  4440.  
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.  
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479.  
  4480.  
  4481.  
  4482.                                                                        PPPPaaaaggggeeee 66668888
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.